I have a table named tblMyUser. MyUserId
is the primary key of the table. When I want to create one User using $myUser = MyUser::create();
and when I am trying to return $myUser->MyUserId
, it does not return the inserted id. Instead, returns a different number.
我有一个名为tblMyUser的表。 MyUserId是表的主键。当我想使用$ myUser = MyUser :: create()时创建一个用户时当我试图返回$ myUser-> MyUserId时,它不会返回插入的id。相反,返回一个不同的数字。
Have anyone any idea how to retrieve the inserted id?
有谁知道如何检索插入的ID?
1 个解决方案
#1
0
If you add user to db in controller, you have to redirect back using id from request in controller and view.
如果在控制器中将用户添加到db,则必须在控制器和视图中使用来自请求的id重定向。
in controller -
在控制器 -
return View::make('VIEW',compact('client'));
web.php -
web.php -
Route::get('view', $user_id->id);
#1
0
If you add user to db in controller, you have to redirect back using id from request in controller and view.
如果在控制器中将用户添加到db,则必须在控制器和视图中使用来自请求的id重定向。
in controller -
在控制器 -
return View::make('VIEW',compact('client'));
web.php -
web.php -
Route::get('view', $user_id->id);