From:             alexr at oplot dot com
Operating system: All
PHP version:      5.2.5
PHP Bug Type:     MSSQL related
Bug description:  MSSQL empty string as NULL

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 bug report at http://bugs.php.net/?id=44325&edit=1
-- 
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=44325&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=44325&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=44325&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=44325&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=44325&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=44325&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=44325&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=44325&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=44325&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=44325&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=44325&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=44325&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=44325&r=globals
PHP 4 support discontinued:   http://bugs.php.net/fix.php?id=44325&r=php4
Daylight Savings:             http://bugs.php.net/fix.php?id=44325&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=44325&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=44325&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=44325&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=44325&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=44325&r=mysqlcfg

Reply via email to