June 2017
Intermediate to advanced
536 pages
9h 49m
English
Much like selecting, inserting, and updating, deleting involves the same set of PDO methods wrapped around the DELETE FROM SQL statement:
<?phptry { $conn = new PDO( "mysql:host=127.0.0.1;dbname=sakila", 'root', 'mL08e!Tq', [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION] ); $statement = $conn->prepare('DELETE FROM payment WHERE payment_id = :payment_id'); $statement->execute([ ':payment_id' => 16046 ]);} catch (PDOException $e) { echo $e->getMessage(), PHP_EOL;}