public function store(Request $request, $id){ $externalAccount = ExternalAccounts::find($id); DB::beginTransaction(); try { $externalAccount->fund_number = 999; $externalAccount->capital_balance = 'kjhkjhkj'; $externalAccount->save(); DB::commit(); } catch (Exception $e){ DB::rollback(); throw $e; }}第一次用Laravel。。capital_balance欄位為int類型,我故意傳進去字串類型,這樣寫入肯定會出錯的。但是上面的fund_number居然寫入成功了,沒有復原= =。。求老司機解答。。mysql引擎沒錯,是InnoDB。
回複內容:
public function store(Request $request, $id){ $externalAccount = ExternalAccounts::find($id); DB::beginTransaction(); try { $externalAccount->fund_number = 999; $externalAccount->capital_balance = 'kjhkjhkj'; $externalAccount->save(); DB::commit(); } catch (Exception $e){ DB::rollback(); throw $e; }}第一次用Laravel。。capital_balance欄位為int類型,我故意傳進去字串類型,這樣寫入肯定會出錯的。但是上面的fund_number居然寫入成功了,沒有復原= =。。求老司機解答。。mysql引擎沒錯,是InnoDB。
我估計是mysql的坑,你拿產生好的sql直接到mysql裡面去執行一下看看