From: Jasen Betts <jasen@xnet.co.nz>
To: pgsql-php@postgresql.org
Subject: Re: sorting query results
Date: 19 Apr 2009 12:20:03 GMT
Message-ID: <gsf4tj$l75$2@reversiblemaps.ath.cx> (raw)
References: <49E9CFBF.4050808@gmail.com>
On 2009-04-18, Piotr Mitoraj <piotr.mitoraj@gmail.com> wrote:
> Hi,
> failing to find the straight-forward answer on the web I hope to find
> some advice in here.
> I want to display the table fetched from the postgres database. The
> headers of the columns are links used to sort the data. Like the
> functionality you have on ebay when you sort according to price or time
> left. I recognized two ways of doing that:
>
> 1. Issue a new query to the database each time the specific sorting was
> requested. In other words, let the database do the sorting and fetch the
> results.
this is the easiest way, and a good start.
> 2. Save the table into php array and and use php built-in functions to
> sort and refresh the table.
unless you're proposing to store the store the array in $SESSION (or
similar) that's not going to work.
also you may get issues if the user opens two different queries in
different windows...
> Which of those methods would be most desired in terms of performance and
> according to "the best practices"?
> What would be possible drawbacks/advantages of those methods.
Here's a third way: use javascript to sort the array.
this gives the best user experience but you should arrange the page
so that those with script turned off can still get the results using
one of the other methods.
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: jasen@xnet.co.nz
Subject: Re: sorting query results
In-Reply-To: <gsf4tj$l75$2@reversiblemaps.ath.cx>
References: <49E9CFBF.4050808@gmail.com> <gsf4tj$l75$2@reversiblemaps.ath.cx>
* 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