src/SweetORM/Database/Query.php
public function sort($column, $type = 'ASC')
    {
        if ($this->queryType !== self::QUERY_SELECT) {
            $this->exception = new QueryException("Sorting can only be applied on SELECT mode!", 0, $this->exception);
            return $this;
        }

        // First lets upper the type.
        $type = strtoupper($type);

        if (! is_string($column)) {
            $this->exception = new QueryException("Sorting column must be an string!", 0, $this->exception);
        }

        if (! $this->validOrderType($type)) {
            $this->exception = new QueryException("Sorting requires a type that is either 'ASC' or 'DESC'!", 0, $this->exception);
            return $this;
        }

        // Validate the column
        if (in_array($column, $this->structure->columnNames)) {
            $this->sortBy = $column;
            $this->sortOrder = $type;
        }

        return $this;
    }
public function sort($column, $type = 'ASC')
    {
        if ($this->queryType !== self::QUERY_SELECT) {
            $this->exception = new QueryException("Sorting can only be applied on SELECT mode!", 0, $this->exception);
            return $this;
        }

        // First lets upper the type.
        $type = strtoupper($type);

        if (! is_string($column)) {
            $this->exception = new QueryException("Sorting column must be an string!", 0, $this->exception);
        }

        if (! $this->validOrderType($type)) {
            $this->exception = new QueryException("Sorting requires a type that is either 'ASC' or 'DESC'!", 0, $this->exception);
            return $this;
        }

        // Validate the column
        if (in_array($column, $this->structure->columnNames)) {
            $this->sortBy = $column;
            $this->sortOrder = $type;
        }

        return $this;
    }
public function sort ( $ column , $ type = 'ASC' ) { if ( $ this -> queryType !== self :: QUERY_SELECT ) { $ this -> exception = new QueryException ( "Sorting can only be applied on SELECT mode!" , 0 , $ this -> exception ) ; return $ this ; } // First lets upper the type. $ type = strtoupper ( $ type ) ; if ( ! is_string ( $ column ) ) { $ this -> exception = new QueryException ( "Sorting column must be an string!" , 0 , $ this -> exception ) ; } if ( ! $ this -> validOrderType ( $ type ) ) { $ this -> exception = new QueryException ( "Sorting requires a type that is either 'ASC' or 'DESC'!" , 0 , $ this -> exception ) ; return $ this ; } // Validate the column if ( in_array ( $ column , $ this -> structure -> columnNames ) ) { $ this -> sortBy = $ column ; $ this -> sortOrder = $ type ; } return $ this ; }
Sort by column value, Ascending or descending
@param string $column Column name to order with.
@param string $type Either ASC or DESC for the order type.
@return Query $this The current query stack.
Sort by column value Ascending or descending