0
我需要執行這兩個查詢,但插入將發生在一個表上(僅限第一個查詢)。如果我先把query9,它會執行,否則query3。我怎樣才能將數據一次插入到兩個表中?
$query9 = $con->prepare("INSERT INTO complete_status (ID, hotel_id,
floor_id, room_id, pull_chrdsw_status, emergency_status, nurse_callsw_status, cmr_status, foodsw_status, bedside_cancelsw_status ,nurse_distress_status, bcssw_status ,final_status,date1, Time) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,CURRENT_TIMESTAMP,CURRENT_TIMESTAMP)");
$query9->bind_param("iiiiiiiiiiiii", $ID, $HotelID ,$SectorID, $RoomID, $pull_chrdsw_status, $emergency_status, $nurse_callsw_status, $cmr_status, $foodsw_status,$bedside_cancelsw_status, $nurse_distress_status, $bcssw_status,$statuss);
if($value->NurseCallSwStats != $Uploadedpkt->RoomStatus[$key]->NurseCallSwStats)
{
if($DebugMode===TRUE)// Test mode with debugg outputs
{
echo "<br>";
echo "laundry change";
}
$Difference_Flag=TRUE;
$nurse_callsw_status = $Uploadedpkt->RoomStatus[$key]->NurseCallSwStats;
$query3->execute();
$query9->execute();
}
foreach ($Uploadedpkt->RoomStatus as $key => $value)
{
$nurse_callsw_status = $Uploadedpkt->RoomStatus[$key]->NurseCallSwStats;
$query3->execute();
$query9->execute();
}
尋找存儲過程或觸發事件!在搜索之後,如果你仍然想要一次又一次地運行這兩個查詢(這並不壞),你可以很容易地使用InnoDb表和事務來保護你的數據(事務被激活,如果query9失敗,query3沒有被提交回滾,回滾)MyIsam表不能使用事務。 –