You are here

public function Xml::addOrderBy in Views XML Backend 8

Add an ORDER BY clause to the query.

This is only used to support the built-in random sort plugin.

Parameters

string $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.

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

string $order: Either ASC or DESC.

string $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.

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

File

src/Plugin/views/query/Xml.php, line 284
Contains \Drupal\views_xml_backend\Plugin\views\query\Xml.

Class

Xml
Views query plugin for an XML query.

Namespace

Drupal\views_xml_backend\Plugin\views\query

Code

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