• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Count how many users there are


i would like to use active record to build a select query, and then return the volume of that query in my view.

I wish to show how many users are registered in something i am practicing building with CI!

I tried using mysql_num_rows but that didn't work!

Any help would be very gratefully received.

[eluser]Phil Sturgeon[/eluser]
echo count($query->result_array());

That's great!

Thank you very much indeed, i did see count somewhere but didn't think of trying it.

Thanks again!

[eluser]Glen Swinfield[/eluser]
You can also use:


Which is quicker?


[eluser]Glen Swinfield[/eluser]
In terms of processing time? It's negligible unless you are using it thousands of times. Basically a CI num_rows() function calls mysql_num_rows() eventually I would think - or could in fact call count($query->result_array()) anyway. I've never really looked through the DB files to see exactly what goes on, but generally the fewer function calls the quicker it is.

But don't get too hung up on it because it will be the database itself that slows your apps down, not a few extra function calls.

thanks a million for this!!!

Keep up the good work

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

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