X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id BA085566B7 for ; Mon, 28 Feb 2005 18:15:01 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 93847-01 for ; Mon, 28 Feb 2005 18:14:55 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.192]) by svr1.postgresql.org (Postfix) with ESMTP id 640CF566D0 for ; Mon, 28 Feb 2005 18:14:42 +0000 (GMT) Received: by wproxy.gmail.com with SMTP id 49so664781wri for ; Mon, 28 Feb 2005 10:14:38 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=FWWmye+/6Dy5B/XyvvjTD7lxl0+MLns1rpD+BJ25Rrg9I+cCK+0HqcqTMwZv+N0MJnbGJLRNfJYH1FDYUVXH4oBr86VRhRCNepjC4qFPkbI8kULPdQL/tBTHWy+KwUktZrqv5EkZf5+ZEQVLyETJ1Z5cgysRtr93FcZtoq6bYHk= Received: by 10.54.17.52 with SMTP id 52mr127519wrq; Mon, 28 Feb 2005 10:14:38 -0800 (PST) Received: by 10.54.59.22 with HTTP; Mon, 28 Feb 2005 10:14:38 -0800 (PST) Message-ID: <330532b605022810144884dd42@mail.gmail.com> Date: Mon, 28 Feb 2005 13:14:38 -0500 From: Mitch Pirtle Reply-To: Mitch Pirtle To: pgsql-php@postgresql.org Subject: Re: grouping query results In-Reply-To: <36567.10.0.4.254.1109584103.squirrel@webmail.arbodienst-limburg.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <36567.10.0.4.254.1109584103.squirrel@webmail.arbodienst-limburg.nl> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.06 tagged_above=0 required=5 tests=AWL, RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200502/40 X-Sequence-Number: 3014 On Mon, 28 Feb 2005 10:48:23 +0100 (CET), Joolz 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