【发布时间】:2017-03-04 10:49:04
【问题描述】:
$store_list = array();
$this->db->select('user_time');
$this->db->from('users');
$this->db->where('staff_id',$userid);
$result = $this->db->get();
$result= $result->result();
foreach($result as $rows){
array_push($store_list, $rows["user_time"]);
}
return $store_list;
我在一个模型中编写了一个函数,其中包含上述代码,当用户的 id 作为参数传递时,它会获取用户的时间,并将用户的时间返回给控制器函数。
但我收到以下错误:Fatal Error: Cannot use object of type stdClass as array
是什么导致了这个错误?有什么想法吗?
注意:sql 查询返回所有匹配的记录。它可以是一条或多条记录。
【问题讨论】:
标签: php codeigniter