[eluser]Robert M.[/eluser]
Hi @ all together.
This will be my first time here in the CI Forum. A have a small problem with understading how i can access an result in controller.
I got an error message like \"Trying to get property of non-object\" on line...
I want to do some like this.
Code:
function get_something($some_var){
$this->load->model(\'some_model\',\'\',TRUE);
$data[\'query\'] = $this->some_model->get_some_thing($some_var);
if($data[\'query\']->col2==some_value){ //<--this will be the line where i get the error.
$this->load->view(\'view_1\',$data);
}else{
$this->load->view(\'view_2\',$data);
}
}
i know my mistake but i don\'t understand how i can access the value. normally in the view i do some like this
Code:
foreach($query as $row):
echo \"col2: \".$row->col2;
and so on but i want access the vaule in the controller
the function in some_model looks like this...
Code:
function get_some_thing($some_var){
$this->db->select(\'col1\');
$this->db->select(\'col2\');
$this->db->select(\'col3\');
$this->db->where(\'col1\',$some_var);
$data = $this->db->get(\'some_table\');
return $data->result();
}