#26820 [Opn->Fbk]: mssql_fetch_row BIT field problem

From: Date: Mon, 19 Jan 2004 04:02:58 +0000
Subject: #26820 [Opn->Fbk]: mssql_fetch_row BIT field problem
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-53554@lists.php.net to get a copy of this message
ID: 26820 Updated by: sniper@php.net Reported By: subspace at wanadoo dot nl -Status: Open +Status: Feedback Bug Type: MSSQL related Operating System: Debian Linux 2.4.20 PHP Version: 4.3.4 New Comment: Please try using this CVS snapshot: http://snaps.php.net/php4-STABLE-latest.tar.gz For Windows: http://snaps.php.net/win32/php4-win32-STABLE-latest.zip Previous Comments: ------------------------------------------------------------------------ [2004-01-06 15:56:15] subspace at wanadoo dot nl 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 this bug report at http://bugs.php.net/?id=26820&edit=1

« previous php.bugs (#53554) next »