CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2006
    Posts
    352

    [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

  2. #2
    Join Date
    Jan 2006
    Posts
    352

    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
  •  





Click Here to Expand Forum to Full Width

Featured