本文整理汇总了PHP中table_sql::get_sql_sort方法的典型用法代码示例。如果您正苦于以下问题:PHP table_sql::get_sql_sort方法的具体用法?PHP table_sql::get_sql_sort怎么用?PHP table_sql::get_sql_sort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类table_sql
的用法示例。
在下文中一共展示了table_sql::get_sql_sort方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
/**
* override parent class method, because we may want to specify a default sort
*
* @return xxx
*/
function get_sql_sort()
{
// if user has specified a sort column, use that
if ($sort = parent::get_sql_sort()) {
return $sort;
}
// if there is a "fullname" column, sort by first/last name
if ($this->has_column('fullname')) {
$sort = 'u.firstname, u.lastname';
if ($this->has_column('attempt')) {
$sort .= ', ha.attempt ASC';
}
return $sort;
}
// no sort column, and no "fullname" column
return '';
}
示例2: get_sql_sort
/**
* Get the SQL fragment to sort by.
*
* This is overridden to sort by timemodified and ID by default. Many items happen at the same time
* and a second sorting by ID is valuable to distinguish the order in which the history happened.
*
* @return string SQL fragment.
*/
public function get_sql_sort()
{
$columns = $this->get_sort_columns();
if (count($columns) == 1 && isset($columns['timemodified']) && $columns['timemodified'] == SORT_DESC) {
// Add the 'id' column when we are using the default sorting.
$columns['id'] = SORT_DESC;
return self::construct_order_by($columns);
}
return parent::get_sql_sort();
}