function TableSort::orderByHeader

Order the query based on a header array.

Parameters

$header: Table header array.

Return value

SelectQueryInterface The called object.

See also

theme_table()

File

includes/tablesort.inc, line 42

Class

TableSort
Query extender class for tablesort queries.

Code

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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.