Re: Retrieving result of COUNT(*) with PHP - Mailing list pgsql-php

From Frank Bax
Subject Re: Retrieving result of COUNT(*) with PHP
Date
Msg-id 5.2.1.1.0.20070328164533.009fcdc0@pop6.sympatico.ca
Whole thread Raw
In response to Retrieving result of COUNT(*) with PHP  (Lynna Landstreet <lynna@spidersilk.net>)
List 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 by date:

Previous
From: Mihail Mihailov
Date:
Subject: Re: Retrieving result of COUNT(*) with PHP
Next
From: "Gavin M. Roy"
Date:
Subject: Re: Retrieving result of COUNT(*) with PHP