1
我想從laravel中的存儲過程中獲取多個結果集。有什麼辦法可以做到這一點? 目前,我可以使用下面的代碼獲取單個行的數據:如何從laravel中的mysql存儲過程中獲取多個結果集
$result = DB::statement('CALL user_login(' . $userId . ',"'
. $password . '",'
. '@success'.','
. '@first_Name'
);
$res = DB::select('select @success AS success, @first_Name AS firstName);
Here is my stored procedure:
DELIMITER //
DROP PROCEDURE IF EXISTS user_login//
create procedure user_login (IN userid VARCHAR(50),
IN password VARCHAR(50),
out success int,
OUT first_Name VARCHAR(255),
)
begin
declare count int(1);
set count =0;
select firstName, count(*)
into first_Name, count
from `tmc`.user where user_id = userid and pwd=password;
if count >0 then
set success =0;
else
set success=1;
end if;
end//