如何使用 LIKE 语句创建 PDO 参数化查询? [英] How do I create a PDO parameterized query with a LIKE statement?
本文介绍了如何使用 LIKE 语句创建 PDO 参数化查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的尝试:
$query = $database->prepare('SELECT * FROM table WHERE column LIKE "?%"');
$query->execute(array('value'));
while ($results = $query->fetch())
{
echo $results['column'];
}
推荐答案
我发帖后马上想通了:
$query = $database->prepare('SELECT * FROM table WHERE column LIKE ?');
$query->execute(array('value%'));
while ($results = $query->fetch())
{
echo $results['column'];
}
这篇关于如何使用 LIKE 语句创建 PDO 参数化查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文