国产+高潮+在线,国产 av 仑乱内谢,www国产亚洲精品久久,51国产偷自视频区视频,成人午夜精品网站在线观看

在webman中使用事務(wù)問題

shanyi

問題描述

我是在webman用使用GatewayWorker,之后做一些數(shù)據(jù)庫的查詢新增操作

  // 啟動(dòng)事務(wù)
  Db::startTrans();
  try {
    $Hardwaredata = json_decode(trim($param), true);
      if ($Hardwaredata === null || !array_key_exists("xwst", $Hardwaredata)) {
          $this->StatusReturn(0, $client_id);
          return;
      }
  if($Hardwaredata['xwst']==1){
      if($boxinfo){
              //執(zhí)行一些數(shù)據(jù)庫查詢和插入的操作
              Gateway::sendToClient($client, $send_datas);
              return;
          }else{
              Gateway::sendToClient($client, $send_datas);
              return;
      }
  }

    DB::commit();//提交至數(shù)據(jù)庫
} catch (\Throwable $e) {
    DB::rollback();//數(shù)據(jù)庫回滾
}

我在使用事務(wù)的時(shí)候,我在Gateway::sendToClient 給用戶發(fā)送消息 我就想不執(zhí)行下面代碼了 我就return了,但是貌似這個(gè)會(huì)變成數(shù)據(jù)庫的數(shù)據(jù)沒有提交,這樣數(shù)據(jù)沒有插入成功。這種情況怎么辦呀

1646 3 1
3個(gè)回答

Gin

return 前 提交事務(wù)啊

  • 暫無評(píng)論
tanhongbin

人才 你終于出現(xiàn)了 事務(wù) 必須提交 然后 最好是使用try catch 防止 出現(xiàn)大量事務(wù)不提交 導(dǎo)致死鎖 問題

  • 暫無評(píng)論
TM

不提交也不回滾嗎

  • 暫無評(píng)論
年代過于久遠(yuǎn),無法發(fā)表回答
??