You are here: Re: Need to substitute #where# with $where « PHP Programming Language « IT news, forums, messages
Re: Need to substitute #where# with $where

Posted by comp.lang.php on 10/09/61 11:42

noone wrote:
> comp.lang.php wrote:
>
> > if ($willLimitByDB) $sql = preg_replace('/#([^#]+)#/i', '$$1',
> > $sql);
>
> > This does not give me the results I want, instead of the value of
> > $where in $sql, I literally get '$where' instead.
>
> > How do I substitute #where# with $where?
>
> > Thanx
> > Phil
>
>
> given: $sql="select * from table";
> and $where="where a = 'a'";
>
> $sql .= $where;
> //concatenate it before you edit it...
> if ($willLimitByDB) $sql = preg_replace('/#([^#]+)#/i', '$$1', $sql);

Thanx but you were looking at the wrong "WHERE.."

the query is this

"SELECT id, first_name, last_name, (SELECT count(id) #where#) as
paginate_total, email, address, city, state, zip, phone FROM person
$where "

You want "#where#" inside the subselect substituted with $where

I got it though thanx to someone that knows RegExp modifiers

$sql = preg_replace('/#([^#]+)#/ie', '$$1', $sql);

Phil

 

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

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