Home > Article > Backend Development > Detailed explanation of order method of ThinkPHP CURD method_PHP tutorial
The order method of the ThinkPHP CURD method belongs to one of the coherent operation methods of the model. This method is used to sort the results of the operation .
The specific usage is as follows:
$Model->where('status=1')->order('id desc')->limit(5)->select();
Note: There is no order for consecutive operation methods. You can change the calling order at will before calling the select method.
Supports sorting of multiple fields , for example:
$Model->where('status=1')->order('id desc,status')->limit(5)->select();
If desc or asc collation is not specified, the default is asc.
If your field conflicts with the mysql keyword, it is recommended to call it in array mode, for example:
$Model->where('status=1')->order(array('order','id'=>'desc'))->limit(5)->select();