|
-
March 13th, 2009, 04:18 PM
#1
[RESOLVED] [MySQL 5.1 & PHP] Prepared STMT with REGEX
This is SQL query stored in PHP's var:
PHP Code:
$sql = 'SELECT t1.for FROM t1, t2 WHERE t1.for = t2.for && t1.for REGEXP \'[^0-9]?[^0-9]\'';
Question mark in a middle of regexp statement, is supposed to be a binding placeholder, for prepared statement!
So when I escape it like:
PHP Code:
$sql = 'SELECT t1.for FROM t1, t2 WHERE t1.for = t2.for && t1.for REGEXP \'[^0-9]\\\?[^0-9]\'';
It just escaped special meaning in regexp itself and is now litteral symbol which is part of a pattern.
I want it to become(?) a binding placeholder inside of regexp pattern.
Ipsens
-
March 13th, 2009, 10:29 PM
#2
Re: [MySQL 5.1 & PHP] Prepared STMT with REGEX
It doesn't matter anymore, as I've found a solution.
It is as follows:
PHP Code:
$sql = 'SELECT t1.for FROM t1, t2 WHERE t1.for = t2.for && t1.for REGEXP CONCAT(\'[^0-9]+\', ?, \'[^0-9]+\')';
And Voila! 
Now ? placeholder works for this prepared select statement.
Ipsens
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|