Skip site navigation (1) Skip section navigation (2)

sorting query results

From: Piotr Mitoraj <piotr(dot)mitoraj(at)gmail(dot)com>
To: pgsql-php(at)postgresql(dot)org
Subject: sorting query results
Date: 2009-04-18 13:03:59
Message-ID: 49E9CFBF.4050808@gmail.com (view raw or flat)
Thread:
Lists: pgsql-php
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.

2. Save the table into php array and and use php built-in functions to 
sort and refresh the table.

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.

Regards,
Piotr


Responses

pgsql-php by date

Next:From: BrewDate: 2009-04-18 14:05:03
Subject: Re: sorting query results
Previous:From: Brian FehrleDate: 2009-04-16 22:55:51
Subject: Re: phpinfo() doesn't show postgres as a configured module

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group