Blogger Information
Blog 56
fans 3
comment 1
visits 50693
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
myqli面向对象和PDO——2018年4月26日
沈斌的博客
Original
680 people have browsed it

mysqli面向对象更新操作,PDO删除

mysqli_update.php

实例

<?php

$dbhost='localhost';
$dbuser='root';
$dbpassword='root';
$dbname='user';

$db=new mysqli($dbhost,$dbuser,$dbpassword,$dbname);

if ($db->connect_errno){
    echo $db->connect_errno.':'.$db->connect_error;
}

$stmt=$db->prepare("UPDATE staf SET salary=9000 WHERE staff_id=?;");

$stmt->bind_param("i",$id);
$id=3;

$stmt->execute();
echo '成功更新了'.$db->affected_rows.'条记录';

$stmt->close();
$db->close();

运行实例 »

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

pdo_delete.php

实例

<?php
/医院
*简化预处理
*/
$pdo=new PDO('mysql:dbname=user','root','root');

$id=8;
//预处理语句
$sql="DELETE FROM staf WHERE staff_id=:id;";
$stmt=$pdo->prepare($sql);
$stmt->bindParam(':id',$id,PDO::PARAM_INT);

$stmt->execute();


echo '成功删除了'.$stmt->rowCount().'条记录';

运行实例 »

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


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