Home > Backend Development > PHP Tutorial > Detailed explanation of the order method tutorial of ThinkPHP CURD method

Detailed explanation of the order method tutorial of ThinkPHP CURD method

WBOY
Release: 2016-07-25 08:53:11
Original
1071 people have browsed it
  1. $Model->where('status=1')->order('id desc')->limit(5)->select();
Copy code

Note: There is no order for consecutive operation methods, and the order of calls can be changed at will before the select method is called.

Supports sorting of multiple fields, such as:

  1. $Model->where('status=1')->order('id desc,status')->limit(5)->select();
Copy code

If no desc or asc sorting rule is specified, the default is asc.

If there is a conflict between the field and the mysql keyword, it is recommended to call it in array mode, for example:

  1. $Model->where('status=1')->order(array('order','id'=>'desc'))->limit(5)-> ;select();
Copy code


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