一尘不染

如何使用LIKE语句创建PDO参数化查询?

php

这是我的尝试:

$query = $database->prepare('SELECT * FROM table WHERE column LIKE "?%"');

$query->execute(array('value'));

while ($results = $query->fetch()) 
{
    echo $results['column'];
}

阅读 273

收藏
2020-05-26

共1个答案

一尘不染

我发布后马上想通了:

$query = $database->prepare('SELECT * FROM table WHERE column LIKE ?');
$query->execute(array('value%'));

while ($results = $query->fetch())
{
    echo $results['column'];
}
2020-05-26