Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ActiveRecord + CodeIgniter - Return single value from query, not in array form

Say you construct an activerecord query that will always just return a single value, how do you just address that single value instead of getting an array in return? For instance I am using an ActiveRecord query to return the SUM of a single column, it will only return this one single SUM, instead of having to parse the array is there a way to assign the value as a function return equal to that value instead of getting an array?

like image 527
txmail Avatar asked Apr 20 '10 02:04

txmail


1 Answers

$query = $this->db->get(); // your ActiveRecord query that will return a col called 'sum'

echo $query->row('sum');
like image 124
Bjørn Børresen Avatar answered Oct 18 '22 21:10

Bjørn Børresen