From: | Frank Bax <fbax(at)sympatico(dot)ca> |
---|---|
To: | pgsql-php(at)postgresql(dot)org |
Subject: | Re: Retrieving result of COUNT(*) with PHP |
Date: | 2007-03-28 21:03:53 |
Message-ID: | 5.2.1.1.0.20070328164533.009fcdc0@pop6.sympatico.ca |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | Postg토토 핫SQL : Postg토토 핫SQL 메일 링리스트 : 2007-03-28 이후 PGSQL-PHP 21:03 |
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"
From | Date | Subject | |
---|---|---|---|
Next Message | Mihail Mihailov | 2007-03-28 21:05:11 | Re: Retrieving result of COUNT(*) with PHP |
Previous Message | Gavin M. Roy | 2007-03-28 20:48:36 | Re: Retrieving result of COUNT(*) with PHP |