pdo更新数据
$pdo = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
//准备SQL语句,占位符我们不再用?,用"命名占位符" $sql="update erj_user set freeze_money=:freeze_money where id=:id ";
//创建预处理对象
$stmt = $pdo->prepare($sql);
$stmt->execute(['freeze_money'=>$cha_freeze_money,'id'=>$row['user_id']]);
$data_stmt=$stmt->rowCount();
$res_1=$redis->zadd('frozen_user',$time,json_encode(['task'=>'frozen_user','task_time'=>$time,'task_params'=>['frozen_id'=>$lastId,'user_id'=>$row['buy_id']]])); if($res_1){ $buy_id=$row['buy_id']; $sql="update erj_user set usermoney=:usermoney,sellmoney=:sellmoney,freeze_money=:freeze_money where id=:id "; //创建预处理对象 $stmt = $pdo->prepare($sql); $stmt->execute(['usermoney'=>0,'sellmoney'=>0,'freeze_money'=>$tot_freeze_money,'id'=>$buy_id]); $data_stmt=$stmt->rowCount(); if($stmt->rowCount()>0) { echo '<h3>成功更新'.$stmt->rowCount().'条</h3>'; }else { echo '<h3>更新失败</h3>'; print_r($stmt->errorInfo()); exit; } }
世界上最美的风景,是自己努力的模样