| 7 entity.inc | public EntityFieldQuery::fieldOrderBy($field, $column, $direction = 'ASC') |
| 8 entity.query.inc | public EntityFieldQuery::fieldOrderBy($field, $column, $direction = 'ASC') |
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.
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.
File
- includes/
entity.inc, line 874
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;
}
Login or register to post comments