Home  >  Article  >  Backend Development  >  Detailed explanation of order method of ThinkPHP CURD method_PHP tutorial

Detailed explanation of order method of ThinkPHP CURD method_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:24:48865browse

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();

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/825321.htmlTechArticleThe order method of ThinkPHP CURD method is one of the coherent operation methods of the model, which is used to sort the results of the operation . The specific usage is as follows: $Model-where('status=1')-order('id des...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn