From: Mitch Pirtle <mitch.pirtle@gmail.com>
To: pgsql-php@postgresql.org
Subject: Re: grouping query results
Date: Mon, 28 Feb 2005 13:14:38 -0500
Message-ID: <330532b605022810144884dd42@mail.gmail.com> (raw)
In-Reply-To: <36567.10.0.4.254.1109584103.squirrel@webmail.arbodienst-limburg.nl>
References: <36567.10.0.4.254.1109584103.squirrel@webmail.arbodienst-limburg.nl>
On Mon, 28 Feb 2005 10:48:23 +0100 (CET), Joolz
<joolz@arbodienst-limburg.nl> wrote:
>
> I have the feeling that this is a very common question, how do you
> people handle it? I looked at a lot of script sites, but no luck.
What I do is run a single query for all employees, then iterate over
the array in PHP for the counts.
The alternative of running several queries seems a bit heavy-handed to
me, but that is because I am always trying to make life easier for the
database server :-)
Note that many database libraries (PEAR::DB, ADOdb) also have
capabilities of returning counts of recordsets, so with two queries
you would be done. But I still like the first approach, as it is not
tied to the database or require external libraries to support.
-- Mitch
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: mitch.pirtle@gmail.com
Subject: Re: grouping query results
In-Reply-To: <330532b605022810144884dd42@mail.gmail.com>
References: <36567.10.0.4.254.1109584103.squirrel@webmail.arbodienst-limburg.nl> <330532b605022810144884dd42@mail.gmail.com>
* 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