Reply to Re: How would I write a regexp on a MySQL query

Your name:

Reply:


Posted by Marcin Dobrucki on 03/01/06 13:28

laredotornado@zipmail.com wrote:
>
> Using PHP 4 and MySQL 4, how would I write a function such that it
> takes a valid MySQL query, and a column on which to order the query,
> and return a new query ordered by that column?
>
> $query = formNewQuery($query, $orderByCol);
>
> An assumption you can make is that the query will never have multiple
> columns on which to order -- e.g. ("ORDER BY COL_A, COL_B"), however
> the query could contain the "DESC" keyword -- "ORDER BY COL_A DESC".

require_once ('DB.php'); // PEAR::DB
//.. $db =& initialize connection, etc.

$query = 'SELECT * FROM table ORDER BY ! !';
$param = array('column_name', $order);
// where $order = 'ASC' or 'DESC' or ''
$res =& $db->query($query, $param);

// voilá!

//Marcin

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация