<?php $id = 5; try { $pdo = new PDO('mysql:host=localhost;dbname=meuBancoDeDados', $username, $password); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $stmt = $pdo->prepare('DELETE FROM minhaTabela WHERE id = :id'); $stmt->bindParam(':id', $id); $stmt->execute(); echo $stmt->rowCount(); } catch(PDOException $e) { echo 'Error: ' . $e->getMessage(); } ?>
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