TP5.1 在使用sqlserver数据库时,模型查询时field字段和order字段不能同时使用解决方案(包含TP5.0)

烂漫一生 提交于 2019-12-05 08:36:10

 

 

 

 tp5.1 解决方案

 

找到  thinkphp/library/think/db/Query.php目录 

找到  

public function field  方法

 

 if (isset($this->options['order'])) {
unset($this->options['order']);
}

在下面补充红框这段代码即可

TP5.0解决方案

public function count($field = '*')
{
//这里的countValue 是我拷贝的value方法,避免影响到其他的操作
return (int) $this->countValue('COUNT(' . $field . ') AS tp_count', 0);
}
我们拷贝一份过后,在下面的代码
if (isset($this->options['field'])) {
unset($this->options['field']);
}
后面补一句
if (isset($this->options['order'])) {
unset($this->options['order']);
}
就行了

 

 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!