tablesort_sql

  1. drupal
    1. drupal6
    2. drupal7
Versionen
drupal6 – drupal7 tablesort_sql($header, $before = '')

Create an SQL sort clause.

This function produces the ORDER BY clause to insert in your SQL queries, assuring that the returned database table rows match the sort order chosen by the user.

Übergabeparameter

$header An array of column headers in the format described in theme_table().

$before An SQL string to insert after ORDER BY and before the table sorting code. Useful for sorting by important attributes like "sticky" first.

Rückgabewert

An SQL string to append to the end of a query.

Verwandte Themen

▾ 2 functions call tablesort_sql()

forum_get_topics in modules/forum/forum.module
node_admin_nodes in modules/node/node.admin.inc
Form builder: Builds the node administration overview.

Code

includes/tablesort.inc, line 153

<?php
function tablesort_sql($header, $before = '') {
  $ts = tablesort_init($header);
  if ($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']);

    // Sort order can only be ASC or DESC.
    $sort = drupal_strtoupper($ts['sort']);
    $sort = in_array($sort, array('ASC', 'DESC')) ? $sort : '';

    return " ORDER BY $before $field $sort";
  }
}
?>

Kommentare

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen