Use a model query in a view - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Use a model query in a view (/showthread.php?tid=10454) |
Use a model query in a view - El Forum - 07-31-2008 [eluser]Xtrex[/eluser] Hi, Iam using a model to preform a query: Code: function noticias_url($uri,$tipo) { How can I use the information passed by this controller in the "noticias" view? And how can I use $query->num_rows()? Code: $this->load->model('noticiar', '', TRUE); Use a model query in a view - El Forum - 07-31-2008 [eluser]Yash[/eluser] Read [url="http://ellislab.com/codeigniter/user-guide/database/active_record.html"]user guide - All database functions are here with less coding[/url] Use a model query in a view - El Forum - 07-31-2008 [eluser]Xtrex[/eluser] I can use all the db functions, and everything that is displayed in the user guide.. But I cant retrieve de data of a model to the view.. I only can do if I perform the query in the controller.. Use a model query in a view - El Forum - 07-31-2008 [eluser]Xtrex[/eluser] with the print_r it returns: Array ( [0] => stdClass Object ( [cod_noticia] => 1 [titulo] => isto é um teste [descricao] => descricao [noticia] => noticia [tags] => paulo, hehe [data] => [uri] => isto-e-um-teste [tipo] => 1 ) ) I cant used like an array, how can I use it? Use a model query in a view - El Forum - 07-31-2008 [eluser]Hannes Nevalainen[/eluser] If you would like to use num_rows() you have to return $query (not $query->result()). If you want to show your data in your view you will get it like this: Code: //View |