Alex Pavlov
Alex Pavlov

Reputation: 581

CI active record. get()->result() error

Why this code doesn't work? Error call in 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 Fatal error: Call to a member function result() on boolean in

Upvotes: 0

Views: 63

Answers (1)

Praveen Kumar
Praveen Kumar

Reputation: 2408

Try this

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

    }

Upvotes: 1

Related Questions