In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "how to use the order method in thinkphp3.2". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
The order method in thinkphp3.2, which is used to sort the results of operations, is one of the model coherent operation methods, which is equivalent to an order by clause in the select statement. The usage is "$Model- > where ()-> order ()-> limit ()-> select ()".
This article operating environment: Windows10 system, ThinkPHP3.2 version, Dell G3 computer.
How to use order method in thinkphp3.2
Order method is one of the coherent operation methods of the model, which is used to sort the results of operations.
The usage is as follows:
$Model- > where ('status=1')-> order (' id desc')-> limit (5)-> select ()
Note: there is no order for coherent operation methods, and the order of calls can be changed before the select method is called.
Support sorting of multiple fields, for example:
$Model- > where ('status=1')-> order (' id desc,status')-> limit (5)-> select ()
If no desc or asc collation is specified, the default is asc.
If your field conflicts with the mysql keyword, it is recommended to call it in an array, for example:
Model- > where ('status=1')-> order (array (' order','id'= > 'desc'))-> limit (5)-> select ()
Add:
Thinkphp cannot use two solutions for sorting-> order ()!
Use ThinkPHP, only to find that sorting cannot be done using-> order ($order).
$order = "info.date2 desc"
It's a pity that order turns out to be order by date2 limit in this way. Desc is gone.
Solution 1:
There can be no spaces on either side of the $order, $order = "info.date2 desc"; (correct). $order = "info.date2 desc"; (error! )
Solution 2:
Open the file: d:\ WebSite\ Zbphp.com\ www\ ThinkPHP\ Extend\ Model\ ViewModel.class.php
Change line 136 to $array = explode ('', trim ($order)); add trim to save.
This is the end of the content of "how to use the order method in thinkphp3.2". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.