<?php //The code example deletes three rows. It prints the number of affected rows. $dsn = "mysql:host=localhost;dbname=mydb"; $user = "user12"; $passwd = "12user"; $pdo = new PDO($dsn, $user, $passwd); $id = 12; //In this SQL statement, we delete rows with ids 1, 2, and 3. The number of deleted rows is stored in the $nrows variable. $nrows = $pdo->exec("DELETE FROM countries WHERE id IN (1, 2, 3)"); //We print the number of deleted rows. echo "The statement affected $nrows rows\n"; ?>
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter