Q:

doing a foreach on queries using codeigntier?

I'm trying to do a foreach on my model using codeigniter, but it's giving me an error and returning the results.
Here's the code:
public function read(){
        $questions; //array
        $query = $this->db->get('questions');
        foreach($query->result() as $row){
            $getAnswers = $this->db->get_where('answers', array('question_id'=>$row['question_id]']), 4);
            $questions= $getAnswers;

           }

        return $questions;
     }

and this is the error: 

Fatal error: Cannot use object of type stdClass as array in

A:

Access row as an object:
$getAnswers = $this->db->get_where('answers', 
                   array('question_id'=>$row->question_id), 4);

