From: Bruno Wolff III <bruno@wolff.to>
To: Nathaniel Price <nprice@tesseract.net>
Cc: scott.marlowe <scott.marlowe@ihs.com>
Cc: pgsql-general@postgresql.org
Cc: pgsql-php@postgresql.org
Subject: Re: Reordering results for a report
Date: Sat, 13 Dec 2003 17:47:32 -0600
Message-ID: <20031213234732.GA30707@wolff.to> (raw)
In-Reply-To: <3FDA43E2.5090902@tesseract.net>
References: <Pine.LNX.4.33.0312121331320.18667-100000@css120.ihs.com>
<3FDA43E2.5090902@tesseract.net>
On Fri, Dec 12, 2003 at 14:40:34 -0800,
Nathaniel Price <nprice@tesseract.net> wrote:
> Sorry, that's not really what I'm looking for. When I said that the sort
> order could be arbitrary, I meant /arbitrary/. As in "no amount of ORDER
> BYs will save me from this one" arbitrary; the records could be in any
> order the user specifies.
>
> The idea is that in PHP I'd be using an array to keep track of the
> custom order that the results should be returned in, using the array
> index to store the sorting order and the values to store the table's
> primary key, like so (note that this isn't the code I'm using, it's just
> an example):
>
> <?php
> $sort[0] = 3; //First record to return (3 is the primary key of the record)
> $sort[1] = 1; //Second record to return
> $sort[2] = 2; //Third record to return
> ... //and so on.
> ?>
It would be possible to use this array in a query, but this wouldn't
work well for large data sets as you would be sending the whole array
back and forth a lot. Presumably the reason you want to do the sort
in the database is because the dataset is large enough that you don't
want to buffer the data in PHP in the first place.
I think the temp table solution won't be that simple either. You will
need connection pooling and some way to keep requests from the same
web session using the same postgres session.
You may want to use regular tables which are named by session id and
the have some clean up process that removes tables that are no longer
needed.
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: bruno@wolff.to, nprice@tesseract.net, scott.marlowe@ihs.com, pgsql-general@postgresql.org
Subject: Re: Reordering results for a report
In-Reply-To: <20031213234732.GA30707@wolff.to>
References: <Pine.LNX.4.33.0312121331320.18667-100000@css120.ihs.com> <3FDA43E2.5090902@tesseract.net> <20031213234732.GA30707@wolff.to>
* 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