You are here

public function ConfigEntityQuery::addOrderBy in Configuration Views 8

Same name and namespace in other branches
  1. 2.0.x src/Plugin/views/query/ConfigEntityQuery.php \Drupal\config_views\Plugin\views\query\ConfigEntityQuery::addOrderBy()

Add an ORDER BY clause to the query.

Parameters

$table: The table this field is part of. If a formula, enter NULL. If you want to orderby random use "rand" as table and nothing else.

$field: The field or formula to sort on. If already a field, enter NULL and put in the alias.

$order: Either ASC or DESC.

$alias: The alias to add the field as. In SQL, all fields in the order by must also be in the SELECT portion. If an $alias isn't specified one will be generated for from the $field; however, if the $field is a formula, this alias will likely fail.

$params: Any params that should be passed through to the addField.

Overrides Sql::addOrderBy

File

src/Plugin/views/query/ConfigEntityQuery.php, line 83

Class

ConfigEntityQuery
This query is able to work with config entities.

Namespace

Drupal\config_views\Plugin\views\query

Code

public function addOrderBy($table, $field = NULL, $order = 'ASC', $alias = '', $params = []) {
  if ($alias) {
    $this->sorting[$alias] = $order;
  }
  elseif ($field) {
    $this->sorting[$field] = $order;
  }
}