Welcome Guest, Not a member yet? Register   Sign In
Query for 1 variable from database table. Looking for optimized code.
#1

[eluser]brandontran[/eluser]
I can get the variable 'country' from the database table,but it isn't very clean looking to me.

To all the code optimizers out there, what is the simplest way to get the variable country from this table?


$this->db_dash->select('country');
$this->db_dash->where('country_code', $country_code);
$query = $this->db_dash->get('country_table');
if ($query->num_rows() > 0)
{
$row = $query->row();
$country_title = $row->country;
}
#2

[eluser]Christopher Blankenship[/eluser]
Code:
$limit = 1;
$query = $this->db_dash->get_where('country', array('country_code' => $country_code), $limit);
This would be one way to clean up your code using get_where().




Theme © iAndrew 2016 - Forum software by © MyBB