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

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b38879-2c136.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b38879-2c136.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?