public function TableSortExtender::orderByHeader in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/lib/Drupal/Core/Database/Query/TableSortExtender.php \Drupal\Core\Database\Query\TableSortExtender::orderByHeader()
Order the query based on a header array.
Parameters
array $header: Table header array.
Return value
\Drupal\Core\Database\Query\SelectInterface The called object.
See also
File
- core/
lib/ Drupal/ Core/ Database/ Query/ TableSortExtender.php, line 42 - Contains \Drupal\Core\Database\Query\TableSortExtender.
Class
- TableSortExtender
- Query extender class for tablesort queries.
Namespace
Drupal\Core\Database\QueryCode
public function orderByHeader(array $header) {
$this->header = $header;
$ts = $this
->init();
if (!empty($ts['sql'])) {
// Based on code from db_escape_table(), but this can also contain a dot.
$field = preg_replace('/[^A-Za-z0-9_.]+/', '', $ts['sql']);
// orderBy() will ensure that only ASC/DESC values are accepted, so we
// don't need to sanitize that here.
$this
->orderBy($field, $ts['sort']);
}
return $this;
}