我已经尝试了'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();