RPeraltaJr
3/5/2018 - 7:16 PM

Delete Query

source: wiki.hashphp.org/PDO_Tutorial_for_MySQL_Developers

<?php 

try {
    $id = "5";
    $stmt = $db->prepare("DELETE FROM table WHERE id=:id");
    $stmt->bindValue(':id', $id, PDO::PARAM_STR);
    $stmt->execute();
    $affected_rows = $stmt->rowCount();

} catch(PDOException $ex) {
    echo "An Error occured!";
    // echo "\nPDO::errorInfo():\n";
    // print_r($dbh->errorInfo());
}