<?php /** * 删除数据 */ $pdo = new PDO('mysql:host=localhost;dbname=data','root','root'); $sql = "delete from stu where id = :id"; $stmt = $pdo->prepare($sql); if($stmt->execute(['id'=>5])) { echo '<h3>成功删除'.$stmt->rowCount().'条</h3>'; }else { echo '<h3>删除失败</h3>'; print_r($stmt->errorInfo()); exit; }
点击 "运行实例" 按钮查看在线实例