array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'mysql-xdevapi-tableselect.orderby.php', 1 => 'TableSelect::orderby', ), 'up' => array ( 0 => 'class.mysql-xdevapi-tableselect.php', 1 => 'mysql_xdevapi\\TableSelect', ), 'prev' => array ( 0 => 'mysql-xdevapi-tableselect.offset.php', 1 => 'TableSelect::offset', ), 'next' => array ( 0 => 'mysql-xdevapi-tableselect.where.php', 1 => 'TableSelect::where', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/mysql_xdevapi/mysql_xdevapi/tableselect/orderby.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(No version information available, might only be in Git)
TableSelect::orderby — Set select sort criteria
$sort_expr
, mixed ...$sort_exprs
): mysql_xdevapi\TableSelectSets the order by criteria.
sort_expr
The expressions that define the order by criteria. Can be an array with one or more expressions, or a string.
sort_exprs
Additional sort_expr parameters.
A TableSelect object.
示例 #1 mysql_xdevapi\TableSelect::orderBy() example
<?php
$session = mysql_xdevapi\getSession("mysqlx://user:password@localhost");
$schema = $session->getSchema("addressbook");
$table = $schema->getTable("names");
$result = $table->select('name', 'age')
->orderBy('name desc')
->execute();
$row = $result->fetchAll();
print_r($row);
?>
以上示例的输出类似于:
Array ( [0] => Array ( [name] => Sam [age] => 42 ) [1] => Array ( [name] => John [age] => 42 ) )