Home >Backend Development >PHP Tutorial >Two solutions for Thinkphp unable to use -)order() sorting! _PHP Tutorial

Two solutions for Thinkphp unable to use -)order() sorting! _PHP Tutorial

WBOY
WBOYOriginal
2016-07-13 10:28:46885browse

Using ThinkPHP, I found that I cannot use ->order($order) to sort.

$order = " info.date2 desc ";

Unfortunately, the result of writing order like this becomes order by date2 limit... desc is missing.


Solution 1:

There cannot be any spaces on both sides of $order, $order = "info.date2 desc"; (correct). $order = "info.date2 desc"; (Error!)



Solution 2:

Open the file: D:WebSiteZbphp.comwwwThinkPHPExtendModelViewModel.class.php

Modify line 136 to $array = explode(' ', trim($order)); add trim Save it, as shown in the picture:




It is recommended to use the second method, but we hope that thinkphp official website can correct this small problem to prevent users from modifying the kernel code themselves. by default7#zbphp.com


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/780965.htmlTechArticleUse ThinkPHP, but found that ->order($order) cannot be used to sort. $order = " info.date2 desc "; Unfortunately, the result of writing order like this becomes order by date2 limit... desc is missing...
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