是否可以使用 PDO 在一个 PHP 函数中创建 2 个查询并执行?
我的代码看起来像这样,但我认为变量混淆了。
$query = $this->db->prepare("REPLACE INTO `content` SET `id` = ?, `user_id` = ?, `date` = ?, `type` = ?, `starttime` = ?, `endtime` = ?, `breaktime` = ?, `worktime` = ?, `za` = ?");
$query->bindValue(1, $setcontentid);
$query->bindValue(2, $user_id);
$query->bindValue(3, $currentdate);
$query->bindValue(4, $settypedropdown);
$query->bindValue(5, $starttime);
$query->bindValue(6, $endtime);
$query->bindValue(7, $breaktime);
$query->bindValue(8, $worktime);
$query->bindValue(9, $za);
$queryusr = $this->db->prepare("UPDATE `users` SET `current_time_saldo` = ?, `current_holiday_saldo` = ? WHERE `id` = ? ");
$queryusr->bindValue(1, $currenttimesaldo);
$queryusr->bindValue(2, $urlaub);
$queryusr->bindValue(3, $user_id);
try{
$query->execute();
$queryusr->execute();
} catch(PDOException $e){
die($e->getMessage());
}