php pdo中的query&prepare语句有什么区别?

时间:2019-09-12 10:10:19

标签: php mysql pdo

我已经尝试了'prepare'和'query'语句从数据库中检索数据。看来他们俩做的是相同的工作。无法区分它们之间的差异。如果有人解释它们之间的区别,那将是有帮助的。

$db_query  = SELECT *FROM " . $this->table . " ORDER BY id ASC;
$statement = $this->connection->query($db_query);
$statement->fetch(PDO::FETCH_ASSOC);
$statement->execute();

$db_query  = SELECT *FROM " . $this->table . " ORDER BY id ASC;
$statement = $this->connection->prepare($db_query);
$statement->fetch(PDO::FETCH_ASSOC);
$statement->execute();

0 个答案:

没有答案