批改状态:未批改
老师批语:
<?php
//更新操作
//1.连接数据库
$pdo = new PDO('mysql:host=127.0.0.1;dbname=php;','root','root');
//2.执行操作
$sql = 'UPDATE `staff` SET `position`=:position WHERE `id`=:id';//语句模板
$stmt=$pdo->prepare($sql);
//$stmt->bindValue('position','公安所长',PDO::PARAM_STR);
//$stmt->bindValue('id','4',PDO::PARAM_INT);
$stmt->execute(['position'=>'公安警员','id'=>'4']);
if($stmt->rowCount()>0){
echo '成功更新'.$stmt->rowCount().'条记录';
}
//3.关闭数据库连接
$pdo = null ;点击 "运行实例" 按钮查看在线实例
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号