【发布时间】:2016-05-27 05:38:01
【问题描述】:
为什么这段代码不起作用? foreach 调用出错。
$notifications = $this->db->select('id, shopping_region_id')
->from('push_notifications')
->where('date<=NOW()')
->get()->result();
foreach ($notifications as $notification)
{
$test = $this->db->select('user_id, shopping_region_id')
->from('user')
->where('shopping_region_id=',$notification->shopping_region_id)
->get()->result();
print_r($test);
}
PHP 致命错误:在布尔值中调用成员函数 result()
【问题讨论】:
-
评论你的
->where('date<=NOW()')部分并删除->result();方法,然后print_r($notifications)你的查询,告诉我你得到了什么结果? -
$notifications 变量是否给你正确的结果
-
是的,$notifications 给了我一个正确的结果。
-
@Frazelli 你能告诉我通知结果数组吗?
标签: php codeigniter activerecord