Re: Small regex help?

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

 



Can anyone suggest the correct regex to replace col1,col2... with count(*)
and strip out everything just before ORDER BY?

so for this:
SELECT col1,col2... FROM tbl WHERE filter1 filter2 ORDER BY order1,order2

I would get this:
SELECT count(*) FROM tbl WHERE filter1 filter2

$str = "SELECT col1,col2... FROM tbl WHERE filter1 filter2 ORDER BY order1,order2";

$str = ereg_replace("^SELECT .* FROM (.*) ORDER BY .*",
			"SELECT COUNT(*) FROM \\1", $str);

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux