Blogger Information
Blog 46
fans 3
comment 2
visits 39254
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
PDO预处理实现删除操作 补交2018年4月25日作业(二)
墨雨的博客
Original
555 people have browsed it

PDO预处理删除操作

实例

<?php

/**
 * PDO预处理删除操作
 */

//1.连接数据库,创建PDO对象
$pdo = new PDO('mysql:dbname=php', 'root', 'root');

//2.准备预处理SQL语句,占位符使用命名参数格式:
$sql = "DELETE  FROM kc WHERE `kc_id`=:kc_id";

//3.创建PDO预处理对象
$stmt = $pdo->prepare($sql);

//4.绑定参数并执行SQL语句
$data = ['kc_id'=>20];
$stmt->execute($data);  
echo '<h3>成功删除了'.$stmt->rowCount().'条记录</h3>';

运行实例 »

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


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