I'm working with a MS SQL database that was done by another developer. Im developing a website that interacts with that database. I need to use a stored procedure called LoginR that takes 3 input parameters (LoginName and Passwords) and returns the NickName in the third value. But also, has a "return" command that returns the ID of the user. Here is the procedure as I see on Microsoft SQL Server Managment Studio:
USE [myDataBase]
GO
DECLARE @return_value int,
@NickName nvarchar(100)
EXEC @return_value = [dbo].[msp_LoginR]
@LoginName = N'MyUser',
@Password = N'MyPass',
@NickName = @NickName OUTPUT
SELECT @NickName as N'@NickName'
SELECT 'Return Value' = @return_value
GO
I can run perfectly the stored procedure in PHP in this way:
$procedure = "{call msp_LoginR( ?, ?, ?)}";
$LoginName = $_POST['user'];
$Password = $_POST['password'];
$NickName = '000000000000000000000000000000000000';
$params = array(
array($LoginName, SQLSRV_PARAM_IN),
array($Password, SQLSRV_PARAM_IN),
array($NickName, SQLSRV_PARAM_OUT)
);
$res = sqlsrv_query( $conMS, $procedure, $params);
And after doing that I got my variable $NickName with the correct value. But I can't get that 'Return Value' = @return_value that the Stored procedures send me and it's the user's ID. What I need to do?