pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Stephen van Egmond <svanegmond@bang.dhs.org>
To: Aguinaldo Fagundes Junior <Aguinaldo.Fagundes@vantcom.net>
Cc: pgsql-php@postgresql.org
Subject: Re: Select count
Date: Mon, 6 Nov 2000 09:51:51 -0500
Message-ID: <20001106095151.G19976@bang.dhs.org> (raw)
In-Reply-To: <35DE6A7B82C8D3119B3B00508B8B7A49FA85B2@PAENTMS1>
References: <35DE6A7B82C8D3119B3B00508B8B7A49FA85B2@PAENTMS1>

Aguinaldo Fagundes Junior (Aguinaldo.Fagundes@vantcom.net) wrote:

> Hi there!
> 
> I could not find in documentation, how I can get the result from a query
> using select "count(*)". Today I use a "select * " and after using
> pg_numrows and it woks but I want to know:Is there any other way to get this
> result?

$result = pg_exec($conn, "SELECT count(*) blah blah blah");
$count = pg_result($result, 0, 0);

That gets the first variable from the first row, fast.  If you're using
fetcharray, you can also use the name 'count' I think, or if that
doesn't work, label it with "SELECT count(*) as foo" and ask for foo.


-- 
       ,,,
      (. .)
+--ooO-(_)-Ooo------------ --- -- - - -  -
| Stephen van Egmond  http://bang.dhs.org/





view thread (2+ messages)  latest in thread

Message-ID: <20001106095151.G19976@bang.dhs.org>
Permalink:  ../20001106095151.G19976@bang.dhs.org/
Also on:    postgresql.org/message-id/20001106095151.G19976@bang.dhs.org

 · 

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: svanegmond@bang.dhs.org, Aguinaldo.Fagundes@vantcom.net
  Subject: Re: Select count
  In-Reply-To: <20001106095151.G19976@bang.dhs.org>
  References: <35DE6A7B82C8D3119B3B00508B8B7A49FA85B2@PAENTMS1> <20001106095151.G19976@bang.dhs.org>

* 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