Process result from DB in Controller |
[eluser]SniffTheGlove[/eluser]
Hello, Struggling to get my head around the DB access code in CI and need some help. I am running a function in my model to extract a single value from a MySQL table. Code: function get_Geo_Location_Latitude() In the controller I can assign the result to a variable Code: $main_var['Latitude'] = $this->model_home->get_Geo_Location_Latitude(); Any ideas?
[eluser]mrpaco85[/eluser]
If you're looking for a single value, you might want to use $query->row() instead. Otherwise, you will have to iterate get_Geo_Location_Latitude() in order to get at a specific value. The row() function will return an object with your selected columns as attributes of that object. In your model: Code: function get_Geo_Location_Latitude() In your controller: Code: $latitude = $this->model_home->get_Geo_Location_Latitude(); $latitude now has the value you are looking for. Also, see http://ellislab.com/codeigniter/user-gui...sults.html for more information on generating query results. |
Welcome Guest, Not a member yet? Register Sign In |