Welcome Guest, Not a member yet? Register   Sign In
count all result from a table using where clause
#4

[eluser]aquary[/eluser]
As long as the the condition are good, using DB's count() is always faster than PHP's count() or CI's num_rows(), which require the data to be sent back to PHP for counting.

And you are putting a wrong code/order. The where should be in front of/before the counting part. The way you did would be... "count everything, then assign a condition for the next query" ?

Code:
$this->db
   ->where('condition', 'value')
   ->count_all_results('table');


Messages In This Thread
count all result from a table using where clause - by El Forum - 02-24-2012, 02:06 PM
count all result from a table using where clause - by El Forum - 02-24-2012, 03:56 PM
count all result from a table using where clause - by El Forum - 02-24-2012, 04:34 PM
count all result from a table using where clause - by El Forum - 02-24-2012, 09:19 PM



Theme © iAndrew 2016 - Forum software by © MyBB