PHP mysql REGEXP Prepared Statement

做~自己de王妃 提交于 2019-12-11 09:23:12

问题


I am very new to MYSQL and Prepared Statements. I have a few queries that I need to change to prepared statements. The problem is with this REGEXP query:

$objects = mysql_query("SELECT * FROM $table WHERE parent REGEXP ',". 
    $item .",|^". $item .",|,". $item ."\$|^". 
    $item ."\$'") or die(mysql_error());

How do you go about converting that to a prepared statement with place holders?


回答1:


You should make use of the CONCAT function inside the prepared statement query instead of using the classic . concatenation sign for regular queries. This should do the trick :)



来源:https://stackoverflow.com/questions/11850205/php-mysql-regexp-prepared-statement

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!