Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sqlsrv output param shows garbage when the variable is initialized to a different type #378

Closed
yitam opened this issue Apr 28, 2017 · 1 comment
Assignees

Comments

@yitam
Copy link
Contributor

yitam commented Apr 28, 2017

Tested in Windows, 32bit and 64bit, both NTS.
First, create a simple stored procedure like this

create proc test_out @p1 integer, @p2 integer, @p3 integer output
as
begin
	select @p3 = @p1 + @p2
	print @p3
end
go

Then, in the script, set warnings return as errors then initialize the output param to a non-integer as shown below:

sqlsrv_configure( 'WarningsReturnAsErrors', true );

$v1 = 1;
$v2 = 2;
$v3 = 'str';

$stmt = sqlsrv_query( $conn, "{call test_out( ?, ?, ? )}", array( $v1, $v2, array( &$v3, SQLSRV_PARAM_OUT )));
 
echo "Output: $v3\n";

The output is Output: 3 followed by lots of garbage.

To fix this issue, simply do the following:
sqlsrv_configure( 'WarningsReturnAsErrors', false );

Then we will get Output: 3, as expected.

@Hadis-Knj Hadis-Knj added the bug label May 2, 2017
@Hadis-Knj Hadis-Knj self-assigned this May 2, 2017
Hadis-Knj pushed a commit to Hadis-Knj/msphpsql that referenced this issue May 3, 2017
@Hadis-Knj Hadis-Knj mentioned this issue May 3, 2017
Hadis-Knj pushed a commit that referenced this issue May 4, 2017
@Hadis-Knj
Copy link

Fixed in in PR #381

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants