Home php教程 php手册 ThinkPHP CURD方法之order方法详解

ThinkPHP CURD方法之order方法详解

Jun 06, 2016 pm 08:21 PM
thinkphp

ThinkPHP CURD方法的order用于对操作的结果排序。这篇文章主要介绍了order方法的用法,需要的朋友可以参考下

ThinkPHP CURD方法的order方法属于模型的连贯操作方法之一,该方法用于对操作的结果排序。

具体用法如下:

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

注意:连贯操作方法没有顺序,可以在select方法调用之前随便改变调用顺序。

支持对多个字段的排序,例如:

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

如果没有指定desc或者asc排序规则的话,默认为asc。

如果你的字段和mysql关键字有冲突,那么建议采用数组方式调用,,例如:

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

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

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to run thinkphp project How to run thinkphp project Apr 09, 2024 pm 05:33 PM

How to run thinkphp project

There are several versions of thinkphp There are several versions of thinkphp Apr 09, 2024 pm 06:09 PM

There are several versions of thinkphp

How to run thinkphp How to run thinkphp Apr 09, 2024 pm 05:39 PM

How to run thinkphp

How to install thinkphp How to install thinkphp Apr 09, 2024 pm 05:42 PM

How to install thinkphp

Which one is better, laravel or thinkphp? Which one is better, laravel or thinkphp? Apr 09, 2024 pm 03:18 PM

Which one is better, laravel or thinkphp?

Development suggestions: How to use the ThinkPHP framework to implement asynchronous tasks Development suggestions: How to use the ThinkPHP framework to implement asynchronous tasks Nov 22, 2023 pm 12:01 PM

Development suggestions: How to use the ThinkPHP framework to implement asynchronous tasks

ThinkPHP6 data encryption and decryption: protecting sensitive data security ThinkPHP6 data encryption and decryption: protecting sensitive data security Aug 25, 2023 pm 10:52 PM

ThinkPHP6 data encryption and decryption: protecting sensitive data security

ThinkPHP6 backend management system development: realizing backend functions ThinkPHP6 backend management system development: realizing backend functions Aug 27, 2023 am 11:55 AM

ThinkPHP6 backend management system development: realizing backend functions

See all articles