Select::orderBy

public function Select::orderBy

public Select::orderBy($field, $direction = 'ASC')

Orders the result set by a given field.

If called multiple times, the query will order by each specified field in the order this method is called.

If the query uses DISTINCT or GROUP BY conditions, fields or expressions that are used for the order must be selected to be compatible with some databases like PostgreSQL. The PostgreSQL driver can handle simple cases automatically but it is suggested to explicitly specify them. Additionally, when ordering on an alias, the alias must be added before orderBy() is called.

Parameters

$field: The field on which to order. The field is escaped for security so only valid field and alias names are possible. To order by an expression, add the expression with