|
CollectionFind::sortSet the sorting criteria Description
public mysql_xdevapi\CollectionFind mysql_xdevapi\CollectionFind::sort(string
$sort_expr )Sort the result set by the field selected in the sort_expr argument. The allowed orders are ASC (Ascending) or DESC (Descending). This operation is equivalent to the 'ORDER BY' SQL operation and it follows the same set of rules. Parameters
Return ValuesA CollectionFind object that can be used to execute the command, or to add additional operations. ExamplesExample #1 mysql_xdevapi\CollectionFind::sort example
The above example will output something similar to: array(2) { [0]=> array(4) { ["_id"]=> string(28) "00005b6b53610000000000000106" ["age"]=> int(18) ["job"]=> string(6) "Butler" ["name"]=> string(6) "Alfred" } [1]=> array(4) { ["_id"]=> string(28) "00005b6b53610000000000000107" ["age"]=> int(42) ["job"]=> string(6) "Butler" ["name"]=> string(8) "Reginald" } } |