1 select.inc public SelectQueryExtender::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. Additionally, when ordering on an alias, the alias must be added before orderBy() is called.

Parameters

string $field: The field on which to order.

string $direction: The direction to sort. Legal values are "ASC" and "DESC". Any other value will be converted to "ASC".

Return value

SelectQueryInterface: The called object.

Overrides SelectQueryInterface::orderBy

File

core/includes/database/select.inc, line 919
Contains classes and interfaces for Select queries.

Class

SelectQueryExtender
The base extender class for Select queries.

Code

public function orderBy($field, $direction = 'ASC') {
  $this->query->orderBy($field, $direction);
  return $this;
}