Home > php教程 > php手册 > Thinkphp 无法使用-)order() 排序的两种解决办法!

Thinkphp 无法使用-)order() 排序的两种解决办法!

WBOY
Release: 2016-06-21 08:48:04
Original
1041 people have browsed it

使用ThinkPHP,却发现无法使用->order($order)来排序。

$order = " info.date2 desc ";

很遗憾的是这样写结果order却变成了 order by date2 limit ... desc不见了。


解决办法一:

$order 里面两边不能有任何空格,$order = "info.date2 desc";(正确)。$order = " info.date2 desc";(错误!)



解决办法二:

打开文件:D:\WebSite\Zbphp.com\www\ThinkPHP\Extend\Model\ViewModel.class.php

修改第136行,改成 $array = explode(" ", trim($order));加上trim 保存即可,如图所示:




推荐使用第二种方法,不过期待thinkphp官网可以修正这个小问题,免得用户自己修改内核代码。by default7#zbphp.com




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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template