Let's say I want to select records where
Id = 30. Prepared statements allow two ways of binding parameters:
$id = 30; $q = $conn->prepare("SELECT * FROM pdo_db WHERE id > ?"); $q->execute(array($id)); // Here above ID will be passed
$sth = $conn->prepare("SELECT `id`, `title` FROM `pdo_db` WHERE `id` > :id"); $sth->execute(array( ':id' => 30 ));
Both are working fine and give accurate results but I am not able to get the exact differences between these two nor when I should use one or another?