У меня проблема с получением данных при попытке сохранить данные. Я хочу получить значение после того, как я вставил данные, я имею в виду данные после того, как он вставил.
Это мой контроллер
контроллер. php
$transactionmemo = DB::connection('sqlsrv2')->insert('sp_Crewprogrammemo_Insert ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?',
array($crewprogrammemo_id,
$crewprogrammemoNumber,
$showFocusId,
$showName,
$crewprogrammemoDescription,
$crewprogrammemoIsapproved,
$crewprogrammemoApprovedby,
$crewprogrammemoApproveddate,
$crewprogrammemoIsdisabled,
$crewprogrammemoDisabledby,
$crewprogrammemoDisableddate,
$crewprogrammemoCreatedby,
$crewprogrammemoCreateddate,
$crewprogrammemoModifiedby,
$crewprogrammemoModifieddate
));
$lastinsertedid = $transactionmemo['crewprogrammemo_id'];
dd($lastinsertedid)
Я получил нулевые данные, мой crewprogrammemo_id
сначала равен нулю, но значение будет создано внутри хранимой процедуры.
Хранимая процедура:
ALTER PROCEDURE [dbo].[sp_Crewprogrammemo_Insert]
@crewprogrammemo_id AS varchar(50),
@crewprogrammemo_number AS varchar(125),
@show_focus_id AS varchar(50),
@show_name AS varchar(255),
@crewprogrammemo_description AS varchar(1000),
@crewprogrammemo_isapproved AS tinyint,
@crewprogrammemo_approvedby AS varchar(50),
@crewprogrammemo_approveddate AS datetime,
@crewprogrammemo_isdisabled AS tinyint,
@crewprogrammemo_disabledby AS varchar(255),
@crewprogrammemo_disableddate AS datetime,
@crewprogrammemo_createdby AS varchar(255),
@crewprogrammemo_createddate AS datetime,
@crewprogrammemo_modifiedby AS varchar(255),
@crewprogrammemo_modifieddate AS datetime
AS
BEGIN
DECLARE @errormessage as nvarchar(100);
DECLARE @type as nvarchar(2)
SET @type = 'CP'
DECLARE @channel as nvarchar(3)
SET @channel = 'tv7'
EXEC sp_sequencer_transaction @type, @crewprogrammemo_id OUTPUT
IF @crewprogrammemo_id IS NULL OR @crewprogrammemo_id = ''
BEGIN
SET @errormessage = 'Booking request ID null, Booking request cannot be saved!';
RAISERROR (@errormessage, 16, 1);
RETURN;
END
INSERT INTO transaction_crewprogrammemo (crewprogrammemo_id, crewprogrammemo_number, show_focus_id, show_name, crewprogrammemo_description, crewprogrammemo_isapproved, crewprogrammemo_approvedby, crewprogrammemo_approveddate, crewprogrammemo_isdisabled, crewprogrammemo_disabledby, crewprogrammemo_disableddate, crewprogrammemo_createdby, crewprogrammemo_createddate, crewprogrammemo_modifiedby, crewprogrammemo_modifieddate)
VALUES (@crewprogrammemo_id, @crewprogrammemo_number, @show_focus_id, @show_name, @crewprogrammemo_description, @crewprogrammemo_isapproved, @crewprogrammemo_approvedby, @crewprogrammemo_approveddate, @crewprogrammemo_isdisabled, @crewprogrammemo_disabledby, @crewprogrammemo_disableddate, @crewprogrammemo_createdby, @crewprogrammemo_createddate, @crewprogrammemo_modifiedby, @crewprogrammemo_modifieddate)
SELECT
crewprogrammemo_id, crewprogrammemo_number, show_focus_id, show_name,
crewprogrammemo_description, crewprogrammemo_isapproved,
crewprogrammemo_approvedby, crewprogrammemo_approveddate,
crewprogrammemo_isdisabled, crewprogrammemo_disabledby,
crewprogrammemo_disableddate, crewprogrammemo_createdby,
crewprogrammemo_createddate, crewprogrammemo_modifiedby,
crewprogrammemo_modifieddate
FROM
transaction_crewprogrammemo
WHERE
crewprogrammemo_id = @crewprogrammemo_id
END
My crewprogrammemo_id
получит значение после прохождения хранимой процедуры, так как я могу вернуть это значение обратно в контроллер?
Я пытался использовать $transactionmemo['crewprogrammemo_id']
раньше и не получалось - как я могу решить эту проблему?