Detailed explanation of order method of ThinkPHP CURD method_PHP tutorial

WBOY
Release: 2016-07-13 10:24:48
Original
864 people have browsed it

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

Copy after login

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

Copy after login

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();
Copy after login

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...
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!