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