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

 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']);
}
就行了

猜你喜欢

转载自www.cnblogs.com/jian-ge/p/11915544.html
今日推荐