public function EntityFieldQuery::fieldOrderBy in Drupal 7
Orders the result set by a given field column.
If called multiple times, the query will order by each specified column in the order this method is called. Note that entities with empty field values will be excluded from the EntityFieldQuery results when using this method.
Parameters
$field: Either a field name or a field array.
$column: A column defined in the hook_field_schema() of this field. entity_id and bundle can also be used.
$direction: The direction to sort. Legal values are "ASC" and "DESC".
Return value
EntityFieldQuery The called object.
1 call to EntityFieldQuery::fieldOrderBy()
- EntityFieldQuery::tableSort in includes/
entity.inc - Enables sortable tables for this query.
File
- includes/
entity.inc, line 950
Class
- EntityFieldQuery
- Retrieves entities matching a given set of conditions.
Code
public function fieldOrderBy($field, $column, $direction = 'ASC') {
if (is_scalar($field)) {
$field_definition = field_info_field($field);
if (empty($field_definition)) {
throw new EntityFieldQueryException(t('Unknown field: @field_name', array(
'@field_name' => $field,
)));
}
$field = $field_definition;
}
// Save the index used for the new field, for later use in field storage.
$index = count($this->fields);
$this->fields[$index] = $field;
$this->order[] = array(
'type' => 'field',
'specifier' => array(
'field' => $field,
'index' => $index,
'column' => $column,
),
'direction' => $direction,
);
return $this;
}