Cannot use object of type think\\db\\Query as array
时间: 2023-09-16 11:13:14 浏览: 179
PHP JSON出错:Cannot use object of type stdClass as array解决方法
这个错误信息表明代码中试图将一个 think/db/Query 类型的对象当作数组来使用,所以出现了 "Cannot use object of type think\db\Query as array" 的错误。根据引用,这个错误可能是因为在查询数据库时使用了错误的方法,应该使用 queryAll() 方法来获取结果集。如果少了这个方法调用,就会导致后续的代码将该对象当作数组来使用,从而触发错误。因此,需要确保在查询数据库时使用了正确的方法来获取结果集。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [Cannot use object of type yii\db\Connection as array](https://blog.csdn.net/weixin_33704234/article/details/86333848)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *3* [微软内部资料-SQL性能优化2](https://download.csdn.net/download/songsu/1850565)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文