计算机网络/计算机科学与应用/系统/运维/开发

tp5.0报错 Call to a member function toArray() on array

问题:

'resultset_type'=>'array'

使用模型查询,想得到数组结构


使用方式:

$data = $this->alias('a')->join('category c','a.cat_id =c.id')->select()->toArray();


解决:

在database.php中设置返回的数据类型

1、全局改为 'resultset_type'=>'collection'


2、局部 在模型中加入

protected $resultSetType='collection';


世间最珍贵的不是“得不到”和“已失去”,而是现在能把握的幸福。

评论

^