If you use count() you need to execute fetchAll() first, this means you need to get all data from your database first. So, if your result have 10.000 rows, than you will need to fetch it from your database and load into memory (assign it to a variable).
With rowCount() you don't need to fetch data from database, so it is more efficient.
Comments
The easiest way would
The easiest way would be:
Log in or register to post comments
Best way to do this...
Log in or register to post comments
thank you both, I think
thank you both,
I think better is rowCount(),
but count() works too
thanks
Tomas
Log in or register to post comments
Diference
The difference here is:
If you use
count()
you need to executefetchAll()
first, this means you need to get all data from your database first. So, if your result have 10.000 rows, than you will need to fetch it from your database and load into memory (assign it to a variable).With
rowCount()
you don't need to fetch data from database, so it is more efficient.Log in or register to post comments
similarly, you can add an
similarly, you can add an expression. See http://drupal.org/node/1266664
Log in or register to post comments
$countnode = db_query("SELECT
or
http://jobs68.com
Build Drupal website please contact me itqn2004@gmail.com
TanTran
Log in or register to post comments
The other way : countQuery()
countQuery() with dynamic queries is also one of the way to acheive this.
Log in or register to post comments
This is 10x more efficient
This is 10x more resource efficient than using ->rowCount() after execute()
A healthy disregard for the impossible.
Log in or register to post comments
This is the proper way. Be
This is the proper way. Be warned though—stupidly it returns the integer count as a string.
_________
http://marmaladesoul.com
Log in or register to post comments
get count with db_select
Hi
Get count with db_select working fine. In the below code: