致命错误:无法使用stdClass类型的对象作为数组 [英] Fatal error: Cannot use object of type stdClass as array in
本文介绍了致命错误:无法使用stdClass类型的对象作为数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我遇到错误致命错误:不能使用类型stdClass作为数组的对象在第183行,恰好是
I'm getting the error "Fatal error: Cannot use object of type stdClass as array in" on line 183 which happens to be
$getvidids = $ci->db->query("SELECT * FROM videogroupids WHERE videogroupid='$videogroup' AND used='0' LIMIT 10");
foreach ($getvidids->result() as $row){
$vidid = $row['videoid'];
}
任何人都知道上面的代码有什么问题?或者这个错误是什么意思?
Anyone know what's wrong with the above code? Or what this error means?
推荐答案
CodeIgniter将结果行作为对象而不是数组。从用户指南:
CodeIgniter returns result rows as objects, not arrays. From the user guide:
result()
此函数将查询结果作为对象
您必须使用以下符号来访问字段:
You'll have to access the fields using the following notation:
foreach ($getvidids->result() as $row) {
$vidid = $row->videoid;
}
这篇关于致命错误:无法使用stdClass类型的对象作为数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文