Re: Retrieving result of COUNT(*) with PHP

Поиск
Список
Период
Сортировка
От Frank Bax
Тема Re: Retrieving result of COUNT(*) with PHP
Дата
Msg-id 5.2.1.1.0.20070328164533.009fcdc0@pop6.sympatico.ca
обсуждение исходный текст
Ответ на Retrieving result of COUNT(*) with PHP  (Lynna Landstreet <lynna@spidersilk.net>)
Список pgsql-php
At 03:16 PM 3/28/07, Lynna Landstreet wrote:
>I'm trying to use a SELECT COUNT(*) to count how many results would be
>retrieved from a particular query (as part of the process of paginating
>search results).
>
>But I'm having trouble figuring out how to retrieve the result of the
>count in PHP.


Why not simply run your query and then call pg_numrows( )  ?

You didn't show us any php code - this works..

   $res = pg_query( $dbc, 'SELECT COUNT(*)  FROM payperiod');
   $val = pg_fetch_result( $res, 0, 0 );
   var_dump ($val );

might output something like

string(3) "205"


В списке pgsql-php по дате отправления:

Предыдущее
От: Mihail Mihailov
Дата:
Сообщение: Re: Retrieving result of COUNT(*) with PHP
Следующее
От: "Gavin M. Roy"
Дата:
Сообщение: Re: Retrieving result of COUNT(*) with PHP