如果有PDO多重查询,如何获取最后查询的结果?
这里是示例代码
$sql = <<<OEF
CREATE TEMPORARY TABLE SELECT * FROM table WHERE ...;
SELECT * FROM table WHERE ...
OEF;
$stmt = $pdo->prepare($sql);
$stmt->execute($params);
while ($row = $stmt->fetch()) {
//not work
}
[PDO::ATTR_EMULATE_PREPARES
设置为true,以便一次执行许多查询。
$stmt = $pdo->prepare("CREATE TEMPORARY TABLE SELECT * FROM table WHERE ...");
$stmt->execute($params1);
$stmt = $pdo->prepare("SELECT * FROM table WHERE ...");
$stmt->execute($params2);
while ($row = $stmt->fetch()) {
// everything is all right
}