0

我正在尝试将查询转换为参数化查询。

我目前的 PHP/SQL 查询是

SELECT * FROM System WHERE information LIKE '%$sheet%' ORDER BY newest DESC;

我将如何参数化这个?

4

1 回答 1

2

如果$sheet总是一个字符串

    $query = $database->prepare('SELECT * FROM System WHERE information LIKE ? ORDER BY newest DESC');
    $query->bindValue(1, "%$sheet%", PDO::PARAM_STR);
    $query->execute();

那么这应该工作

于 2013-10-29T22:51:33.863 回答