Re: Retrieving result of COUNT(*) with PHP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]




On 3/28/07, Mihail Mihailov <Mihail.Mihailov@xxxxxx> wrote:

Another way to calculate number of rows in the result is to use
pg_num_rows function.
$res = pg_query("SELECT COUNT(*) AS result_count FROM etc. WHERE etc.");
$count = pg_num_rows($res);

I dont think this will work as expected.  PostgreSQL will return 1 row and your $count var will be 1.  If you do SELECT * FROM it would return the proper result.  Not very effective for speed though.

http://www.varlena.com/GeneralBits/120.php has some good suggestions for dealing with count(*) speed issues.

Gavin



[Index of Archives]     [Postgresql General]     [Postgresql Admin]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Yosemite Backpacking]     [Postgresql Jobs]

  Powered by Linux