ID:               44325
 User updated by:  alexr at oplot dot com
 Reported By:      alexr at oplot dot com
 Status:           Open
 Bug Type:         MSSQL related
 Operating System: All
 PHP Version:      5.2.5
 New Comment:

Sorry. This is duplicate of http://bugs.php.net/bug.php?id=40394 bug
with fix :)
Could you please correct my code or approve it?


Previous Comments:
------------------------------------------------------------------------

[2008-03-04 16:09:27] alexr at oplot dot com

Description:
------------
mssql_bind not correctly bind empty strings as parameter value.

I add in php_mssql.c

if(!datalen) {
   datalen = 1;
   maxlen  = 1;
}

After the 

value=(LPBYTE)Z_STRVAL_PP(var);

To fix this problem.
Please add this code to the next PHP realize.

Reproduce code:
---------------
Code 1:
<?php
$cn = mssql_connect($DBSERVER, $DBUSER, $DBPASS);
mssql_select_db($DB, $cn);
$sp = mssql_init("sp_test");
$val = 0;
mssql_bind($sp, "RETVAL", &$val, SQLINT4);
mssql_bind($sp, "@ID", "", SQLVARCHAR, false, 0);
mssql_execute($sp);
mssql_close($cn);
echo $val;
?>
Code 2:
<?php
$cn = mssql_connect($DBSERVER, $DBUSER, $DBPASS);
mssql_select_db($DB, $cn);
$sp = mssql_init("sp_test");
$val = 0;
mssql_bind($sp, "RETVAL", &$val, SQLINT4);
mssql_bind($sp, "@ID", null, SQLVARCHAR, false, 1);
mssql_execute($sp);
mssql_close($cn);
echo $val;
?>

SQL Code

CREATE PROCEDURE sp_test
    @ID varchar(255) null
AS
begin
    if @ID is NULL return 2
    else return 3
END

Expected result:
----------------
1) "3"
2) "2"

Actual result:
--------------
1) "2"
2) "2"


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=44325&edit=1

Reply via email to