是的,当我尝试对之前看起来像这样的变量使用绑定值时,我遇到了问题:
users.firstname LIKE '$firstname%'
现在看起来像这样:
users.firstname LIKE ':firstname%'
但还是不行,也试过了:
users.firstname LIKE :firstname%
并出现一些语法错误..
正确的解决方案是什么?我还考虑在 bindValue(:firstname, $firstname%) 中添加 % 但我也需要在其他不应该有 % 的地方使用 :firstname 。
帮忙谢谢
好的,添加%
到绑定值:
users.firstname LIKE :firstname
And then
$stmt->bindValue(':firstname', $firstname . '%');
但是,既然你说你需要使用:firstname
在其他地方,只需将此实例命名为不同的名称即可:
users.firstname LIKE :firstnamewild
And then
$stmt->bindValue(':firstnamewild', $firstname . '%');
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)