Re: Select count

From: Stephen van Egmond <svanegmond(at)bang(dot)dhs(dot)org>
To: Aguinaldo Fagundes Junior <Aguinaldo(dot)Fagundes(at)vantcom(dot)net>
Cc: pgsql-php(at)postgresql(dot)org
Subject: Re: Select count
Date: 2000-11-06 14:51:51
Message-ID: 20001106095151.G19976@bang.dhs.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-php

Aguinaldo Fagundes Junior (Aguinaldo(dot)Fagundes(at)vantcom(dot)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/

In response to

  • Select count at 2000-11-06 15:38:46 from Aguinaldo Fagundes Junior

Browse pgsql-php by date

  From Date Subject
Next Message Aguinaldo Fagundes Junior 2000-11-06 15:38:46 Select count
Previous Message magnus 2000-11-01 21:06:03 Re: listing databases