ID: 50147 Updated by: u...@php.net Reported By: w at lder dot de -Status: Bogus +Status: Feedback Bug Type: MySQL related Operating System: Linux 2.6.16.21-0.25-default PHP Version: 5.2.11 New Comment:
Wait, ... I didn't get you changed table structure. Can you provide a new var_dump but keep in mind: [2009-11-12 11:05] <Jani_> '' == NULL (true), NULL == NULL (true). Ulf Previous Comments: ------------------------------------------------------------------------ [2009-11-12 10:00:16] j...@php.net Please, ask further question on how to use PHP elsewhere. There are no bugs in this in either PHP or MySQL. ------------------------------------------------------------------------ [2009-11-12 09:33:02] u...@php.net Bogus Why would one return NULL for meta data. NULL = undefined, "NULL" = defined. ------------------------------------------------------------------------ [2009-11-12 09:08:40] w at lder dot de OK, but how can I get the value NULL? I think it is an difference between "NULL" and "". Any idea? Another Example: <?php /* Mysql: CREATE TABLE IF NOT EXISTS `test` ( `hereIsDefaultNULL` int(255) default NULL, `defaultEmptyvarchar` varchar(255) NOT NULL default '' ) */ mysql_connect('localhost','root',''); mysql_select_db('test'); $columns_res = mysql_query('SHOW COLUMNS FROM `test`'); while ($fieldRow = mysql_fetch_assoc($columns_res)) { if ($fieldRow['Default'] == NULL) { echo $fieldRow['Field'] . ' is NULL </br>'; } } ?> Expected result: ---------------- hereIsDefaultNULL is NULL Actual result: -------------- hereIsDefaultNULL is NULL defaultEmptyvarchar is NULL ------------------------------------------------------------------------ [2009-11-12 08:38:18] j...@php.net Replace print_r() with var_dump() and prepare for surprise. ------------------------------------------------------------------------ [2009-11-11 11:28:23] w at lder dot de Here is the result: mysql> SHOW COLUMNS FROM test; +--------------------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +--------------------+--------------+------+-----+---------+-------+ | hereIsDefaultNULL | int(255) | YES | | NULL | | | defaultNULLvarchar | varchar(255) | YES | | NULL | | +--------------------+--------------+------+-----+---------+-------+ ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/50147 -- Edit this bug report at http://bugs.php.net/?id=50147&edit=1