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

实例

<?php

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

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


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

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


//检测是否成功
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