![]() |
Nested data arrays in CI views - howto access? - 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: Nested data arrays in CI views - howto access? (/showthread.php?tid=33782) |
Nested data arrays in CI views - howto access? - El Forum - 09-08-2010 [eluser]mjstenbe[/eluser] Im having major difficulties in prosessing nested MySQL data in my views. See sample data below. Im pulling a set of RSS data from MySQL db to be processed and displayed for the user. The MySQL data is fetched using Code: function get_news($offset=5) { I pass the data to a view, using: Code: $query = $this->db_model->get_news(); I cannot, however, seem to access to this data from my view in any means. I tried looping and printing out the $query-arrays, even accessing them through global variables but nope. Could someone point me to the right directions here, please? What am I doing wrong, or did I miss something obvious ![]() Sample data clip: Code: Array Is there any way to print out all the variable data passed to a specific view? This would be very useful? Any help would be highly appreciated. Thanks, Mika Nested data arrays in CI views - howto access? - El Forum - 09-08-2010 [eluser]n0xie[/eluser] Code: // controller Nested data arrays in CI views - howto access? - El Forum - 09-08-2010 [eluser]smilie[/eluser] Yes, as n0xie pointed out, when passing data to view CI assumes it is an array. So you will have to send it as array to your view as stated here above. Also, you can do this as well: Code: # Controller Regards, Smilie Nested data arrays in CI views - howto access? - El Forum - 09-09-2010 [eluser]mjstenbe[/eluser] Thanks guys for your fast reply. I knew the solution would be simple. ![]() Another quick question: my views need to use some utility function I have written in a separate library class. I tried to include this file on top of the view, but CI doesnt seem to like this. What would be the proper way use my pre-written classes in my CI code? Thanks again, Mika Nested data arrays in CI views - howto access? - El Forum - 09-09-2010 [eluser]Greg Aker[/eluser] Do you have your class in application/libraries? load it up in your controller with: Code: $this->load->library('your_library'); then in the view: Code: $this->your_library_name_here->method_name_here(); or if it's procedural code, you can just use helpers. -greg |