[eluser]Unknown[/eluser]
Hello folks, I am new here and have a small issue.
The problem is with understanding 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.
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);
}
}
Nick Carangi pointed this out, i know my mistake but i don’t understand how i can access the value. normally in the view i do some like this
foreach($query as $row):
echo "col2: ".$row->col2;
and so on but i want access the value in the controller
the function in some_model looks like this…
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();
}