From: subspace at wanadoo dot nl
Operating system: Debian Linux 2.4.20
PHP version: 4.3.4
PHP Bug Type: MSSQL related
Bug description: mssql_fetch_row BIT field problem
Description:
------------
Fields that have the SQL type 'bit' and are nullable return string(1) "0"
for both 0 (false) and NULL values, when using mssql_fetch_row and
similar.
Expected behavior would be to return bool(false) for NULL values.
Reproduce code:
---------------
function vdump($value) {
ob_start();
var_dump($value);
$result = ob_get_contents();
ob_end_clean();
return trim($result);
}
$db = mssql_connect('servername', 'username', 'password');
mssql_query("CREATE TABLE #demo (bitfield BIT NULL, tinyfield TINYINT
NULL)", $db);
mssql_query("INSERT INTO #demo (bitfield,tinyfield) VALUES (0, 0)", $db);
mssql_query("INSERT INTO #demo (bitfield,tinyfield) VALUES (1, 1)", $db);
mssql_query("INSERT INTO #demo (bitfield,tinyfield) VALUES (NULL, NULL)",
$db);
$result = mssql_query("SELECT * FROM #demo", $db);
while ($row = mssql_fetch_row($result))
echo "bit: " . vdump($row[0]) . "\t tiny: " . vdump($row[1]) . "\n";
mssql_query("DROP TABLE #demo", $db);
Expected result:
----------------
bit: string(1) "0" tiny: string(1) "0"
bit: string(1) "1" tiny: string(1) "1"
bit: bool(false) tiny: bool(false)
Actual result:
--------------
bit: string(1) "0" tiny: string(1) "0"
bit: string(1) "1" tiny: string(1) "1"
bit: string(1) "0" tiny: bool(false)
--
Edit bug report at http://bugs.php.net/?id=26820&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=26820&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=26820&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=26820&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=26820&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=26820&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=26820&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=26820&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=26820&r=support
Expected behavior: http://bugs.php.net/fix.php?id=26820&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=26820&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=26820&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=26820&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=26820&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=26820&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=26820&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=26820&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=26820&r=float