我有一个存储过程,该过程执行一系列插入和更新。
INSERT INTO
table
(
email
first_name
last_name
)
values
(
'john.smith@gmail.com'
'John'
'Smith'
)
我正在获取user_id,然后将其插入到另一个表中
DECLARE @user_id as int = scope_identity()
INSERT....
DECLARE @another_id as int = scope_identity()
SELECT @another_id as another_id
然后我最终进行了更新...
UPDATE
使用Larevel的选择,我正在做类似的事情:
$new_account = DB::SELECT('EXEC [dbo].[admin_company_account_holder_insert]
@email = \''.$request['email']')
并且在我的控制器中
dd($new_account[0]->another_id)
但是laravel返回了我:
The active result for the query contains no fields.
此选择是否有误? 以前我也看过这两个问题:
https://laravel.io/forum/08-13-2014-mssql-stored-procedures-returning-id-after-insert
Laravel, get last insert id using Eloquent
谢谢