Home  >  Article  >  PHP Framework  >  How to implement sorting in thinkphp

How to implement sorting in thinkphp

藏色散人
藏色散人Original
2022-12-07 09:23:232456browse

Thinkphp method to implement sorting: 1. Open the corresponding tp file; 2. Obtain the data through the ThinkPHP code; 3. Use the "order('id, status desc')" method to sort the obtained data. Can.

How to implement sorting in thinkphp

The operating environment of this tutorial: Windows 7 system, ThinkPHP version 5, Dell G3 computer.

How does thinkphp implement sorting?

Use the order() function in ThinkPHP to sort the obtained data

The starting point of the problem

Under normal circumstances, it is necessary to obtain The data is organized in reverse chronological order. But I hope it's more than that.

Draw inferences from one example and draw analogies, is it possible to sort by the specified name?

For example, I need to sort by id and status in reverse order?

Solution to the problem

It can be solved by using one order function, no need to use it continuously.

The specific writing method, such as the above requirements, can be written like this:

order('id, status desc')
//desc == descent == 倒序
//因为默认的是顺序。

If you still need to sort and subdivide, you can continue to write in this format.

Recommended learning: "thinkPHP Video Tutorial"

The above is the detailed content of How to implement sorting in thinkphp. For more information, please follow other related articles on the PHP Chinese website!

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