Laravel 5.5.How to get insertID by writing sql natively

from DB::statement ("START TRANSACTION"); I probably think one of his statements is a session link, so I can"t get insertID.

how do you write it in native language?

DB::getPdo ()-> lastInsertId (); always feels unstable

Mar.06,2021

doesn't start transaction open things


transaction:
Open DB::beginTransaction ();
commit DB::commit ();
rollback DB::rollBack ();

ID:
for example, after you new a model, save, that is, insert, the instance object of the model, $model- > id (id is your primary key name)


Native sql is not recommended

Menu