regex - PHP - Replace exact match preg_replace -
I'm trying to implement an lot simple PDO bindValue () function. (For educational purposes only)
So, in the first "frontend" code, I have a SQL query:
Enter the log in value (: Referer ,: Id_cookie ,: id_cookie_com);
And my code that looks like this:
$ stmt-> gt; BindValue (': referer', 'test'); $ Stmt- & gt; Bind value (': id_cookie', 'test2'); $ Stmt- & gt; Byte value (': id_cookie_com', 'test3');
I'm dividing my query, and I'm getting all the parameters that start with ":" in an array that works well.
array ([0] = & gt ;: Referrer [1] =>: id_cookie [2] = & gt ;: id_cookie_com)
But, when I try to change the parameter query, I have to face a small problem.
If I do this:
Public function bundle ($ parameter, $ variable, $ type = zero) {$ this -> Sql = preg_replace ('/' parameter. '/', $ Variable, $ this- & gt; sql); }
I'm receiving it as a result:
Enter the log values (test, test2, test3_com)
< / Pre>I can not manage to remove _com at the end of the query I know why it is here, this is because my preg_replace matches my array with id_cookie , And I started with id_cookie with the variable.
How can I change the whole word to preg_replace ()? Use the word limit:
$ this-> Sql = preg_replace ("/ $ parameter \ b /", $ variable, $ this-> sql); // here __ ^^
Comments
Post a Comment