Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

php / mysql

Status
Not open for further replies.

skuban

Programmer
Jan 31, 2010
1
US
So what IS the best way to efficiently count returned records using php & mysql?

I'm reading conflicting stuff on whether to use "select count *" or "select count(var)"

Thanks guys :)
Scott


------------------------------------------------------
My blog:
 
that question is better asked in the mysql forum.

you might also consider using the foundrows() function.
 
Hi
[ul]
[li]Please use descriptive subjects. "php / mysql" is not.[/li]
[li]Please mark questions as Question. Your post is not News Clip.[/li]
[li]Please post your questions in the suitable forum. Discussion about ""select count *" or "select count(var)"" is not PHP.[/li]
[li]Please post correct code. "select count *" is not.[/li]
[li]Please post complete code. The [tt]join[/tt] and [tt]where[/tt] clauses influences how the query is executed.[/li]
[li]Please specify necessary technical details. The used storage engine influences the way [tt]count()[/tt] works.[/li]
[li]Please do your own research. A Programmer should be able to use the [tt]explain[/tt] statement, measure the execution time and system resources.[/li]
[/ul]


Feherke.
 
If you want a PHP method you can of course use a number of PHP statements such as mysql_num_rows() to get the number of returned rows.

Of course what you can use depends on exactly how you are executing your queries.

Are using using direct mysql_functions,
are you using Pear, or another abstraction layer etc...

We really need more information to provide an accurate answer.



----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top