1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

DB:beginTransaction();ってなに?

Last updated at Posted at 2021-09-17

直接DBにアクセス(保存)する記述。コントローラーに書く。

DB:beginTransaction();
try {
  //略
  DB::commit();
  return ...
} catch (Exception $e) {
  //略
  DB::rollback();
  return ...
}

DB:commitって何?
migrationのコミット?ロールバックはもともとはここから来ていたのですかね

###DB:beginTeansaction();

直訳するとDB:取引開始
なのでここからDB接続しますということ

###DB:commit();

DBへ内容を反映させる
当たり前ですが、コードは上から順番に読み込まれるので
この記述が呼ばれるとDBへ反映される。

###DB:rollback();

DBへの処理は行われずなかったことに
##END

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?