【问题标题】:CI active record. get()->result() errorCI 活动记录。获取()->结果()错误
【发布时间】: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()

【问题讨论】:

标签: php codeigniter activerecord


【解决方案1】:

试试这个

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);

    }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-06-21
    • 1970-01-01
    • 1970-01-01
    • 2014-08-05
    • 1970-01-01
    • 1970-01-01
    • 2013-08-27
    相关资源
    最近更新 更多