tablesort_sql

Versions
4.6 – 6
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.

Parameters

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

Return value

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

Related topics

▾ 12 functions call tablesort_sql()

comment_admin_overview in modules/comment.module
Menu callback; present an administrative comment listing.
forum_get_topics in modules/forum.module
path_overview in modules/path.module
Return a listing of all defined URL aliases.
statistics_node_tracker in modules/statistics.module
statistics_recent_hits in modules/statistics.module
Menu callback; presents the "Recent hits" page.
statistics_top_pages in modules/statistics.module
Menu callback; presents the "Top pages" page.
statistics_top_referrers in modules/statistics.module
Menu callback; presents the "Top referrers" page.
statistics_top_users in modules/statistics.module
Menu callback; presents the "Top users" page.
statistics_user_tracker in modules/statistics.module
user_admin_access in modules/user.module
Menu callback: list all access rules
user_admin_account in modules/user.module
watchdog_overview in modules/watchdog.module
Menu callback; displays a listing of log messages.

Code

includes/tablesort.inc, line 50

<?php
function tablesort_sql($header, $before = '') {
  $ts = tablesort_init($header);
  if ($ts['sql']) {
    $sql = db_escape_string($ts['sql']);
    $sort = strtoupper(db_escape_string($ts['sort']));
    return " ORDER BY $before $sql $sort";
  }
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.