[eluser]Michal1[/eluser]
Hello guys,
when I want to get some data from database I am using
Code:
return $query->result()
which works perfectly fine for me and I know that it returns array of objects. So then in controller I can do something like
Code:
$data['articles'] = $query;
and then in view for example if I want to display "title" of all articles I do simply
Code:
<?php if (isset($articles)): foreach ($articles as $row) :?>
<?php echo $row->title; ?>
blablabla
And then there is second option, which is return $query->row() which I know returns only one row. So for example when I want to get only one article in model I use
Code:
return $query->row();
but now how to use in controller? I am trying
and then in view
Code:
<?php echo $article->title; ?>
but it does not work so I suppose I dont understand it correctly. Btw of course I missed parts like $query = $this->db->get('something'); in the code here etc. I of course do it in my real code.
Thank you