Blogger Information
Blog 34
fans 0
comment 0
visits 28434
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
425PDO实现删除操作
1A7498的博客
Original
879 people have browsed it
<?php
//简化预处理删除操作
$pdo =new PDO('mysql:dbname=php','root','root');//连接数据库,创建pdo对象
$stmt = $pdo->prepare("DELETE FROM user WHERE `user_id`=:user_id;");//准备sql语句,创建pdo预处理对象
$stmt->execute(['user_id'=>2]);//绑定变量到预处理对象:sql语句中的对象,并执行的sql
?>

QQ截图20180428175718.png

执行删除函数需要细心和慎重,由于sql语句中user_id=后面的冒号没有写导致数据被全部删除~~~









Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post
  • 2018-03-16 11:39:01