pdo删除代码
<?php //1.连接数据库, try { $pdo = new PDO('mysql:dbname=php','root','root'); } catch (PDOException $e) { exit($e->getMessage()); } $sql = "DELETE FROM class WHERE class_id = :class_id "; if($stmt = $pdo->prepare($sql)) { $param = ['class_id'=>3]; if ($stmt -> execute($param)){ if ($stmt->rowCount()>0) { echo '成功删除了'.$stmt->rowCount().'条记录'; } else { echo '没有记录被删除'; } } else { print_r($stmt->errorInfo()); exit(); } }else { print_r($pdo->errorInfo()); exit(); }