public function order(string $sql, array $params = []) : self
    {
        $this->qiterator = null;
        $name = null;
        if (!count($params)) {
            $name = preg_replace('(\s+(ASC|DESC)\s*$)i', '', $sql);
            try {
                $name = $this->getColumn(trim($name))['name'];
            } catch (\Exception $e) {
                $name = null;
            }
        }
        $this->order = [ $sql, $params, $name ];
        return $this;
    }
public function order(string $sql, array $params = []) : self
    {
        $this->qiterator = null;
        $name = null;
        if (!count($params)) {
            $name = preg_replace('(\s+(ASC|DESC)\s*$)i', '', $sql);
            try {
                $name = $this->getColumn(trim($name))['name'];
            } catch (\Exception $e) {
                $name = null;
            }
        }
        $this->order = [ $sql, $params, $name ];
        return $this;
    }
public function order ( string $ sql , array $ params = [ ] ) : self { $ this -> qiterator = null ; $ name = null ; if ( ! count ( $ params ) ) { $ name = preg_replace ( '(\s+(ASC|DESC)\s*$)i' , '' , $ sql ) ; try { $ name = $ this -> getColumn ( trim ( $ name ) ) [ 'name' ] ; } catch ( \ Exception $ e ) { $ name = null ; } } $ this -> order = [ $ sql , $ params , $ name ] ; return $ this ; }
Apply advanced sorting
@param  string $sql    SQL statement to use in the ORDER clause
@param  array  $params optional params for the statement (defaults to an empty array)
@return $this
Apply advanced sorting