Welcome Guest, Not a member yet? Register   Sign In
How I get return number from query COUNT(*)?
#1

[eluser]Rubiz'[/eluser]
Hi there!!

How can I get a query result from COUNT(*)?
My print_r() returns:
Code:
Array ( [0] => stdClass Object ( [COUNT(*)] => 5 ) )

But I tried to get it like $var[0]->COUNT(*), but I knew it would be wrong, and I dont know how to proceed... I know its a basic thing but I dont know it :red:

If someone can help me, thanxs!!
#2

[eluser]Seppo[/eluser]
Well.. the easiest way is to use an alias in your query...
Code:
$this->db->query('SELECT COUNT(*) AS q...');

The hard way is
Code:
$var[0]->{'COUNT(*)'}
#3

[eluser]Rubiz'[/eluser]
So much very pretty thanx Smile
(for the hard way rsrsrs)
#4

[eluser]barbazul[/eluser]
There is even an easier way: using active record "count" method
#5

[eluser]Rubiz'[/eluser]
Right... I'll be exploring this too




Theme © iAndrew 2016 - Forum software by © MyBB