Issue
Here is my code
$users = DB::table('users')->insert(array(
'email_id' => $email_id,
'name' => $name,
));
$lastInsertedID = $users->lastInsertId();
return $lastInsertedID;
I want to get last inserted id for particular record. I have tried using Eloquent ORM. but it didn't work.
Any help would be grateful.
Thank You.
Solution
Use insertGetId()
$id = DB::table('users')-> insertGetId(array(
'email_id' => $email_id,
'name' => $name,
));
Answered By - aynber Answer Checked By - Pedro (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.