放荡! 在数据库中,商品名称的末尾带有问号(死后是生命?)。如何正确编写正则表达式,以便搜索时不考虑方括号中的字符,即问号和其他字符?
下面的选项不起作用。
$article="Is life after death";
$sth = "SELECT * FROM articles WHERE article REGEXP '/.'?'[?%$@&]./'";
$sth = $dbh->prepare($sth);
$sth->bindParam(1,$article,PDO::PARAM_STR);
$sth->execute();
即使数据库中的项目看起来像这样,代码也必须使用$ article变量中的名称在数据库中找到项目名称:%#是生命吗?死后?&。