pg.ddx.io pgsql-php@postgresql.org mailing list archivehelp / color / mirror / Atom feed
From: Frank Bax <fbax@sympatico.ca>
To: pgsql-php@postgresql.org
Subject: Re: Retrieving result of COUNT(*) with PHP
Date: Wed, 28 Mar 2007 17:03:53 -0400
Message-ID: <5.2.1.1.0.20070328164533.009fcdc0@pop6.sympatico.ca> (raw)
In-Reply-To: <C2303737.4AFAD%lynna@spidersilk.net>
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"
view thread (15+ messages) latest in thread
Message-ID: <5.2.1.1.0.20070328164533.009fcdc0@pop6.sympatico.ca> Permalink: ../5.2.1.1.0.20070328164533.009fcdc0@pop6.sympatico.ca/ Also on: postgresql.org/message-id/5.2.1.1.0.20070328164533.009fcdc0@pop6.sympatico.ca ·
reply
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Reply to all the recipients from your mail client; the link fills in the headers below: reply via email Some clients, webmail especially, drop In-Reply-To and References from a link, and the reply then starts a new thread: use the mbox below. To: pgsql-php@postgresql.org Cc: fbax@sympatico.ca Subject: Re: Retrieving result of COUNT(*) with PHP In-Reply-To: <5.2.1.1.0.20070328164533.009fcdc0@pop6.sympatico.ca> References: <C2303737.4AFAD%lynna@spidersilk.net> <5.2.1.1.0.20070328164533.009fcdc0@pop6.sympatico.ca> * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox