0

I have tried the both 'prepare' and 'query' statement to retrieve data from database. It seems both of them do the same work. Can't differentiate the difference between them. It would be helpful, if anyone explain the difference between them.

$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();
tanjiya
  • 173
  • 3
  • 16

0 Answers0