这段代码工作正常:
$query = "SELECT * FROM user WHERE id = 1;";
$stmt = $this->openDb()->prepare($query);
$stmt->execute();
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
为什么此代码不起作用并给我错误Fatal error: Call to a member function fetchAll() on a non-object in
$result_set = $this->openDb()->prepare("SELECT * FROM user WHERE id = 1;")->execute()->fetchAll(PDO::FETCH_ASSOC);