Error "Trying to get property of non-object" using ->row->column_name after CodeIgniter's $this->db->get()
16:59 15 Nov 2011

I'm trying to pass along the question AND the id of the question in the first query and then with that id get that poll's options and add those to the array. Not seeing what I'm doing wronge here.

Here's the error I am getting:

A PHP Error was encountered
Severity: Notice
Message: Undefined property: CI_DB_mysql_result::$row
Filename: models/sitemodel.php
Line Number: 161

A PHP Error was encountered
Severity: Notice
Message: Trying to get property of non-object
Filename: models/sitemodel.php
Line Number: 161

Code:

function getPoll() {
    $this->db->select('site_polls.id, site_polls_questions.poll_question');
    $this->db->from('site_polls');
    $this->db->join('site_polls_questions', 'site_polls_questions.id = site_polls.site_polls_questions_id');
    $this->db->where('site_polls.status_id', 1);
    $this->db->order_by('site_polls.date_posted', 'desc');  
    $this->db->limit(1);
    $query = $this->db->get();
    $id = $query->row->id; 
    
    $this->db->select('site_polls_questions_options.poll_option');
    $this->db->from('site_polls_questions_options');
    $this->db->where('id', $id); 
    $query = $this->db->get();  
    
    return $query->result_array();
}

I'm trying to figure out how I can add the question of the poll into the array.

php codeigniter