我正在使用「Laravel中的雄辯ORM」執行數據庫操作。我只想在數據庫中取最後一個插入ID(不是最大ID)。如何在Eloquent ORM laravel中獲取最後一個插入標識
我搜索了laravel的最後一個插入id雄辯的ORM,我得到了下面的鏈接(Laravel, get last insert id using Eloquent),它指的是從下面的函數「$data->save()
」中獲取最後一個插入id。
但我需要得到
「Model::create($data)
」;
我的查詢:
GeneralSettingModel::create($GeneralData);
User::create($loginuserdata);
我怎樣才能獲取最後插入的ID?
的可能的複製[Laravel,獲得使用雄辯最後插入ID(http://stackoverflow.com/問題/ 21084833/laravel-get-last-insert-id-using-eloquent) –
如果'如果表有一個自動遞增的id'試試這個:https://stackoverflow.com/a/46482971/2815635 – C2486