Excluindo com PDO

PHOTO EMBED

Thu Sep 08 2022 07:52:34 GMT+0000 (Coordinated Universal Time)

Saved by @vmap #php

<?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();
}
?>
content_copyCOPY

https://www.devmedia.com.br/crud-com-php-pdo/28873