如何使用LIKE语句创建PDO参数化查询?我的尝试是:$query = $database->prepare('SELECT * FROM table WHERE column LIKE "?%"');$query->execute(array('value'));while ($results = $query->fetch()) { echo $results['column'];}
3 回答
慕神8447489
TA贡献1780条经验 获得超1个赞
$query = $database->prepare('SELECT * FROM table WHERE column LIKE ?');$query->execute(array('value%'));while ($results = $query->fetch()){ echo $results['column'];}
大话西游666
TA贡献1817条经验 获得超14个赞
吃鸡游戏
TA贡献1829条经验 获得超7个赞
$query = $database->prepare('SELECT * FROM table WHERE column LIKE ?');
$query->bindValue(1, "%$value%", PDO::PARAM_STR);
$query->execute();
if (!$query->rowCount() == 0)
{
while ($results = $query->fetch())
{
echo $results['column'] . "<br />\n";
}
}
else
{
echo 'Nothing found';
}
- 3 回答
- 0 关注
- 617 浏览
添加回答
举报
0/150
提交
取消