Get NULLS LAST SQL.

@param  string $column
@param  string $direction
@return string
185713
protected function getNullsLastSql($column, $direction)
    {
        $sql = $this->config->get('datatables.nulls_last_sql', '%s %s NULLS LAST');

        return sprintf($sql, $column, $direction);
    }
740744
public function getCursor($direction)
    {
        if (isset($this->metaData['paging']['cursors'][$direction])) {
            return $this->metaData['paging']['cursors'][$direction];
        }

        return null;
    }
634963
public function sortByRelation($column, $direction = 'ASC')
    {
        $relations = explode('.', $column);
        $column    = array_pop($relations);

        /** @var \Illuminate\Database\Eloquent\Model $model */
        $model = $this->repository->makeModel();

        $this->instance->getQuery()->orders = [];

        foreach ($relations as $relation) {
            /* @var Relation $relationClass */
            $this->joinRelation($relationClass = $model->{camel_case($relation)}());

            $model = $relationClass->getRelated();
        }

        $selectedColumns = $this->instance->getQuery()->columns;

        $addColumn = DB::raw("{$this->repository->makeModel()->getTable()}.*");

        if (is_array($selectedColumns) && array_search('*', $selectedColumns, true) !== null) {
            $this->instance->getQuery()->columns[array_search('*', $selectedColumns, true)] = $addColumn;
        } else {
            $this->instance->select($addColumn);
        }

        $this->instance->orderBy("{$model->getTable()}.{$column}", $direction);

        return $this;
    }
1271606
function lastSerialID( $table = false, $column = false )
    {
        if ( $this->IsConnected )
        {
            $id = mysqli_insert_id( $this->DBWriteConnection );
            return $id;
        }

        return false;
    }
599862
public static function parseDirection($direction = Order::ASC)
    {
        if (preg_match('/^asc$/i', $direction)) {
            return Order::ASC;
        } else {
            return Order::DESC;
        }
    }
222019
public function lastInsertId(string $table, string $column = 'id')
    {
        $databaseServer = $this->connection->getDatabasePlatform()->getName();
        if (isset($this->databaseSpecificHelpers[$databaseServer])) {
            return $this->databaseSpecificHelpers[$databaseServer]
                ->lastInsertId($table, $column);
        }

        return $this->connection->lastInsertId($table);
    }
730317
public function apply($query, $column, $direction = 'asc')
    {
        $direction = $direction === 'desc' ? 'desc' : 'asc';

        $modelTable = $query->getModel()->getTable();
        $modelKey   = $query->getModel()->getKeyName();

        $translationRelation = $this->getTranslationsRelation($query);

        $translationTable   = $translationRelation->getRelated()->getTable();
        $translationForeign = $translationRelation->getQualifiedForeignKeyName();

        $locale    = app()->getLocale();
        $localeKey = $this->getLocaleKey();

        $supportsIf = $this->databaseSupportsIf($query);

        // build translation subquery to join on, best match first
        $subQueryAlias = uniqid('trans');
        $keyAlias      = uniqid('fk');

        $subQuery = DB::table($translationTable)
            ->select([
                "{$translationForeign} as {$keyAlias}",
                "{$translationTable}.{$column}",
            ])
            ->where(function ($query) use ($locale, $localeKey) {
                /** @var \Illuminate\Database\Query\Builder $query */

                // Check if we need to work with a fallback locale
                $fallback = $this->getFallbackLocale();

                $query->where($localeKey, '=', $locale);

                if ($fallback && $fallback != $locale) {
                    $query->orWhere($localeKey, '=', $fallback);
                }
            });

        if ($supportsIf) {
            $subQuery->orderByRaw("IF(`{$localeKey}` = ?,0,1)", [ $locale ]);
        }



        // build the main query, and join the sub
        $query = $query
            ->select("{$modelTable}.*")
            ->leftJoin(
                DB::raw("(" . $subQuery->toSql() . ") as `{$subQueryAlias}`"),
                function ($join) use (
                    $subQueryAlias,
                    $keyAlias,
                    $modelTable,
                    $modelKey
                ) {
                    /** @var JoinClause $join */
                    $join->on("{$subQueryAlias}.{$keyAlias}", '=', "{$modelTable}.{$modelKey}");
                }
            )
            ->addBinding($subQuery->getBindings(), 'join');

        /** @var Builder $query */
        if ($this->nullLast && $supportsIf) {
            $query->orderBy(
                DB::raw("IF(`{$subQueryAlias}`.`{$column}` IS NULL OR `{$subQueryAlias}`.`{$column}` = '',1,0)")
            );
        }

        $query->orderBy("{$subQueryAlias}.{$column}", $direction);

        return $query;
    }
617608
public function getRowData($column = null)
    {
        $data = $this->_data->getRowData();

        if (!is_null($column)) {
            $data = isset($data[$column]) ? $data[$column] : null;
        }

        return $data;
    }
466435
protected function stripTableForPluck(string $column): ?string
    {
        return \is_null($column) ? $column : \last(\preg_split('~\.| ~', $column));
    }
963949
public function getColumnDetail($column)
    {
        $columns = $this->getColumnDetails();

        return isset($columns[$column]) ? $columns[$column] : null;
    }
524922
public function oldest($column = null)
    {
        if (is_null($column)) {
            $column = $this->model->getCreatedAtColumn() ?? 'created_at';
        }

        $this->query->oldest($column);

        return $this;
    }
522609
public function order($column)
    {
        if (!in_array($column, $this->allowedOrders)) {
            return null;
        }
        
        if (isset($this->order[$column])) {
            $order = strtolower($this->order[$column]) == self::ORDER_ASC ? self::ORDER_DESC : self::ORDER_ASC;
        } else {
            $order = self::ORDER_ASC;
        }

        return $this->getUrl(['order-' . $column => $order]);
    }
358857
function orderBy( $column, $direction = "ASC" ) {

        $clone = clone $this;

        if ($direction===true) {
            $clone->orderBy[] = $column;
        }else{
            $clone->orderBy[] = $this->db->quoteIdentifier( $column ) . " " . $direction;
        }

        return $clone;

    }
1272826
public function orderBy($column, $direction = 'asc')
    {
        $direction = strtolower($direction);

        if (! in_array($direction, ['asc', 'desc'], true)) {
            throw new InvalidArgumentException('Order direction must be "asc" or "desc".');
        }

        $this->{$this->unions ? 'unionOrders' : 'orders'}[] = [
            'column' => $column,
            'direction' => $direction,
        ];

        return $this;
    }
1155401
public function sortby($column, $direction= 'ASC') {
        /* The direction can only be ASC or DESC; anything else is bogus */
        if (!in_array(strtoupper($direction), array('ASC', 'DESC', 'ASCENDING', 'DESCENDING'), true)) {
            $direction = '';
        }

        if (!static::isValidClause($column)) {
            $this->xpdo->log(xPDO::LOG_LEVEL_ERROR, 'SQL injection attempt detected in sortby column; clause rejected');
        } elseif (!empty($column)) {
            $this->query['sortby'][] = array('column' => $column, 'direction' => $direction);
        }
        return $this;
    }
895405
public function getReverseDirection($column, $lowercase = false)
    {
        if (!$this->isSorted($column)) {
            return $lowercase ? \strtolower(SorterRule::ASC) : SorterRule::ASC;
        }

        return $this->sorterRules[$column]->getReverseDirection($lowercase);
    }
660679
public function apply($query, $column, $direction = 'asc')
    {
        $direction = $direction === 'desc' ? 'desc' : 'asc';

        $modelTable = $query->getModel()->getTable();
        $modelKey   = $query->getModel()->getKeyName();

        $query->orderBy("{$modelTable}.{$modelKey}", $direction);

        return $query;
    }