USE [Test]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[phpTest]
@ResultValue int OUTPUT
AS
BEGIN
SET NOCOUNT ON;
SET @ResultValue=13
RETURN 13;
END
And it is working just fine inside Microsoft Studio:
DECLARE @output int
DECLARE @return int
EXEC @return = phpTest @ResultValue = @output OUTPUT
SELECT @return AS 'return', @output AS 'output'
But now I need to get either return or output into the Yii.
Alot of options tested:
$sql = "DECLARE @output int;DECLARE @return int;EXECUTE @return = phpTest @ResultValue = @output OUTPUT"; // either variables or question marks or :variable
$connection = Yii::app()->db;
$command = $connection->createCommand($sql);
$command->bindParam(1,$returnVariable,PDO::PARAM_INT|PDO::PARAM_INPUT_OUTPUT,2); //with or without this
$command->bindParam(':returnVariable',$returnVariable,PDO::PARAM_INT|PDO::PARAM_INPUT_OUTPUT,100); // or with :variable
$command->execute(); //with or without this
$result = $command->queryScalar();
pr($returnVariable);die;