0

我正在使用 pdo 准备好的语句查询我的数据库,但在执行查询后我无法弄清楚如何返回实际查询。
我已经尝试过print_r($statement);,但所做的只是提供 pdo 准备好的查询。任何帮助都感激不尽!

$sql = ("SELECT * FROM `mySite` WHERE `info` LIKE :checkSite OR `users` LIKE :checkSite");
$stmt = $pdo->prepare($sql);
$stmt->bindParam(":checkSite", "%$checkSite%");

$stmt->execute();
$results = $stmt->fetchAll();
foreach($results as $row){
    echo $row['users'];
}
4

1 回答 1

0

This is quite complicated task and one of drawbacks of using prepared statements.

Yet API doesn't offer such a useful feature out of the box. So, the only way to get raw SQL is to parse placeholders manually. There are some home-brewed solutions in this answer

于 2013-08-19T17:33:35.767 回答