Blogger Information
Blog 17
fans 0
comment 0
visits 11635
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
使用PDO进行数据表的删除操作——2月25号
iL的博客
Original
852 people have browsed it

实例

<?php

//1.连接数据库
$pdo=new PDO('mysql:host=127.0.0.1;dbname=php','root','root');

//2.创建预处理对象
$sql='DELETE FROM `staff` WHERE `id`=:id';
$stmt=$pdo->prepare($sql);


//3.执行操作
//$stmt->bindValue(id,9,PDO::PARAM_INT);

//换个方法
$stmt->execute([id=>10]);


//检测是否成功
if($stmt->rowCount()>0){
    echo '成功的删除了'.$stmt->rowCount().'条记录';
}

//关闭连接
$pdo=null;

运行实例 »

点击 "运行实例" 按钮查看在线实例

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