Re: [GENERAL] Reordering results for a report

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On Fri, Dec 12, 2003 at 14:40:34 -0800,
  Nathaniel Price <nprice@xxxxxxxxxxxxx> 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.


[Index of Archives]     [Postgresql General]     [Postgresql Admin]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Yosemite Backpacking]     [Postgresql Jobs]

  Powered by Linux