views and data arrays |
[eluser]edhrx[/eluser]
I gather data and provide an array for a view using $row= $query->row_array(); . However this falls over if no row is returned. I now need to create an array with fieldnames in so the view will work ok. Is it possible to get to the fieldnames of a table to do this....or is there some cute other type of function of which I am unaware :red: best wishes Ed.
[eluser]Michael Wales[/eluser]
You really have two questions here: one, how to gracefully degrade when what you expect to happen does not; and two, how to get the fieldnames from a table. This code can easily be moved out into a model, but I am writing it now as if it's all in the controller. Code: // Run a query we know will fail In your view: Code: if ($page) { Your second question - how do you return all of the fields from a table: this is answered within the first paragraph of the User Guide: Database - Field Metadata. Code: $pages_fields = $this->db->list_fields('pages'); |
Welcome Guest, Not a member yet? Register Sign In |