function _views_query::add_orderby in Views (for Drupal 7) 5
File
- ./
views_query.inc, line 387
Class
Code
function add_orderby($table, $field, $order, $alias = '') {
if (!$alias && $table) {
$alias = $this->use_alias_prefix . $table;
}
elseif ($alias) {
$alias = $this->use_alias_prefix . $alias;
}
if ($table) {
$this
->ensure_table($table);
}
if (!is_array($field)) {
$field = array(
$field,
);
}
foreach ($field as $f) {
// Only fill out this aliasing if there is a table;
// otherwise we assume it is a formula.
if ($table) {
$as = $alias . '_' . $f;
}
else {
$as = $alias;
}
$this
->add_field($f, $table, $as);
$this->orderby[] = "{$as} {$order}";
if ($this->groupby) {
$this
->add_groupby($as);
}
}
}