PHP mysql REGEXP准备语句 [英] PHP mysql REGEXP Prepared Statement

查看:66
本文介绍了PHP mysql REGEXP准备语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对MYSQL和Prepared Statements非常陌生.我有一些查询需要更改为准备好的语句.问题在于此REGEXP查询:

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?

推荐答案

您应该在准备好的语句查询中使用CONCAT函数,而不要使用classic.常规查询的串联符号.这应该可以解决问题:)

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 :)

这篇关于PHP mysql REGEXP准备语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆