PHP Prepared Statements… Bind variable as numeric range in REGEXP?

后端 未结 1 1814
灰色年华
灰色年华 2021-01-20 22:43
$query = \"SELECT * FROM `mytable` WHERE `file` REGEXP \'[:val-9]\'\";
$stmt = $dbh->prepare($query);
$stmt->bindValue(\':val\', \'1\'); //I have also tried 1 with         


        
相关标签:
1条回答
  • 2021-01-20 23:26

    Placeholders can only be used where a value can appear, not embedded in strings. Try:

    $query = "SELECT * FROM `mytable` WHERE `file` REGEXP CONCAT('[', :val, '-9]')";
    
    0 讨论(0)
提交回复
热议问题