DB Select Average

#1
[eluser]ShoeLace1291[/eluser]
How do I display just the average of the column with the select average function? This is my quuery:

Code:
$this->db->select_avg('price');
$this->db->where('restaurant', $restaurant->id);
$query = $this->db->get('menu_items');

#2
[eluser]WanWizard[/eluser]
Code:
$this->db->select_avg('price', 'price');
$this->db->where('restaurant', $restaurant->id);
$query = $this->db->get('menu_items');
$row = $query->row();
echo $row->price;


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.