Welcome Guest, Not a member yet? Register   Sign In
Process result from DB in Controller
#2

[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()
{
    $query = $this->db->query('SELECT geo_defaults_value FROM geo_defaults WHERE geo_defaults_descriptor = "Latitude" ');
    if ($query->num_rows() == 0)
    {
        //show_error('Database is empty!');
    }
    else{  
        $row = $query->row();
        return $row->geo_defaults_value;  //This is how you get a single value
    }
}

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.


Messages In This Thread
Process result from DB in Controller - by El Forum - 07-25-2011, 05:42 PM
Process result from DB in Controller - by El Forum - 07-26-2011, 09:48 AM



Theme © iAndrew 2016 - Forum software by © MyBB