I’ve got an stdClass coming from my database :
$query = $this->db->get('news');
if(isset($options['id']) || $options['limit'] == 1)
return $query->row(0);
And I would like to pass it to my variable :
$data['news'] = $this->front_model->getNews($spec);
so that I can get to any property simply by doing $data['news']->id
but I get this message error:
Message: Object of class stdClass could not be converted to string
why?
Instead of
Use this
It will already fetch the result in array form
http://codeigniter.com/user_guide/database/results.html
first remove the 0 from $query->row() because it only fetches single record. then print_r($data) to see what is coming
Also do this
instead of
Now you are able to call it like this