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

How to implement sorting in thinkphp

藏色散人
Release: 2022-12-07 09:23:23
Original
2574 people have browsed it

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 == 倒序
//因为默认的是顺序。
Copy after login

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!

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