You are here: Re: REGEX: can't seem to replace LIMIT clause in query using preg_replace ($pattern, $replacement, $query) « PHP Programming Language « IT news, forums, messages
Re: REGEX: can't seem to replace LIMIT clause in query using preg_replace ($pattern, $replacement, $query)

Posted by lawrence k on 04/13/06 09:22

OK, my bad, the pattern needed to be case insenstive. This worked:

$pattern = "(.*)limit (.*)";
$replacement = '$1';
$replacement .= "LIMIT $limit,";
$replacement .= '$2';
$query = preg_replace ('/(.*)limit (.*)/i', $replacement, $query);


lawrence k wrote:
> Want to replace the limit clause in a query, but can't get it right.
> What's wrong with this:
>
> $pattern = "(.*)limit (.*)";
> $replacement = '$1';
> $replacement .= "LIMIT $limit";
> $replacement .= '$2';
> $query = preg_replace ($pattern, $replacement, $query);
>
>
> All I get back is:
>
> LIMIT 700

 

Navigation:

[Reply to this 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

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