#50147 [Fbk-Opn]: DEFAULT NULL Values in mysql_query('SHOW COLUMNS FROM `xx`');
ID: 50147 User updated by: w at lder dot de Reported By: w at lder dot de -Status: Feedback +Status: Open Bug Type: MySQL related Operating System: Linux 2.6.16.21-0.25-default PHP Version: 5.2.11 New Comment: set Status to open Previous Comments: [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| | ++--+--+-+-+---+ [2009-11-11 10:44:06] u...@php.net ext/mysql returns whatever MySQL delivers. Please verify that the MySQL prompt returns the result you want. If not, this is a MySQL bug not a PHP bug. Please run on the command line: mysql -uuser -ppassword database... mysql SHOW COLUMNS FROM mytable [2009-11-11 10:35:02] w at lder dot de Description: The attached Code results a wrong result. MySQL: Server Version: 5.0.26 MySQL-Client-Version: 5.0.26 Reproduce code: --- ?php /* MySQL: CREATE TABLE IF NOT EXISTS `test` ( `hereIsDefaultNULL` int(255) default NULL, `defaultNULLvarchar` varchar(255) default NULL ) */ mysql_connect('localhost','user',''); mysql_select_db('test'); $columns_res = mysql_query('SHOW COLUMNS FROM `test`'); while ($fieldRow = mysql_fetch_assoc($columns_res)) { print_r($fieldRow) ; } ? Expected result: Array ( [Field] = hereIsDefaultNULL [Type] = int(255) [Null] = YES [Key] = [Default] = NULL [Extra] = ) Array ( [Field] = defaultNULLvarchar [Type] = varchar(255) [Null] = YES [Key] = [Default] = NULL [Extra] = ) Actual result: -- Array ( [Field] = hereIsDefaultNULL [Type] = int(255) [Null] = YES [Key] = [Default] = [Extra] = ) Array ( [Field] = defaultNULLvarchar [Type] = varchar(255) [Null] = YES [Key] = [Default] = [Extra] = ) -- Edit this bug report at http://bugs.php.net/?id=50147edit=1
#50147 [Bgs]: DEFAULT NULL Values in mysql_query('SHOW COLUMNS FROM `xx`');
ID: 50147 User updated by: w at lder dot de Reported By: w at lder dot de Status: Bogus Bug Type: MySQL related Operating System: Linux 2.6.16.21-0.25-default PHP Version: 5.2.11 New Comment: 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 Previous Comments: [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| | ++--+--+-+-+---+ [2009-11-11 10:44:06] u...@php.net ext/mysql returns whatever MySQL delivers. Please verify that the MySQL prompt returns the result you want. If not, this is a MySQL bug not a PHP bug. Please run on the command line: mysql -uuser -ppassword database... mysql SHOW COLUMNS FROM mytable [2009-11-11 10:35:02] w at lder dot de Description: The attached Code results a wrong result. MySQL: Server Version: 5.0.26 MySQL-Client-Version: 5.0.26 Reproduce code: --- ?php /* MySQL: CREATE TABLE IF NOT EXISTS `test` ( `hereIsDefaultNULL` int(255) default NULL, `defaultNULLvarchar` varchar(255) default NULL ) */ mysql_connect('localhost','user',''); mysql_select_db('test'); $columns_res = mysql_query('SHOW COLUMNS FROM `test`'); while ($fieldRow = mysql_fetch_assoc($columns_res)) { print_r($fieldRow) ; } ? Expected result: Array ( [Field] = hereIsDefaultNULL [Type] = int(255) [Null] = YES [Key] = [Default] = NULL [Extra] = ) Array ( [Field] = defaultNULLvarchar [Type] = varchar(255) [Null] = YES [Key] = [Default] = NULL [Extra] = ) Actual result: -- Array ( [Field] = hereIsDefaultNULL [Type] = int(255) [Null] = YES [Key] = [Default] = [Extra] = ) Array ( [Field] = defaultNULLvarchar [Type] = varchar(255) [Null] = YES [Key] = [Default] = [Extra] = ) -- Edit this bug report at http://bugs.php.net/?id=50147edit=1
#50147 [Bgs]: DEFAULT NULL Values in mysql_query('SHOW COLUMNS FROM `xx`');
ID: 50147 User updated by: w at lder dot de Reported By: w at lder dot de Status: Bogus Bug Type: MySQL related Operating System: Linux 2.6.16.21-0.25-default PHP Version: 5.2.11 New Comment: Here the var_dump: array(6) { [Field]= string(17) hereIsDefaultNULL [Type]= string(8) int(255) [Null]= string(3) YES [Key]= string(0) [Default]= NULL [Extra]= string(0) } array(6) { [Field]= string(19) defaultEmptyvarchar [Type]= string(12) varchar(255) [Null]= string(2) NO [Key]= string(0) [Default]= string(0) [Extra]= string(0) } Yes, I know that '' == NULL (true), but in mySQL : mysql SELECT '' IS NULL; ++ | '' IS NULL | ++ | 0 | ++ mysql SELECT NULL IS NULL; +--+ | NULL IS NULL | +--+ |1 | +--+ Previous Comments: [2009-11-12 10:06:28] u...@php.net 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 [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. 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=50147edit=1
#50147 [Bgs]: DEFAULT NULL Values in mysql_query('SHOW COLUMNS FROM `xx`');
ID: 50147 User updated by: w at lder dot de Reported By: w at lder dot de Status: Bogus Bug Type: MySQL related Operating System: Linux 2.6.16.21-0.25-default PHP Version: 5.2.11 New Comment: Hi Jani, right, thank you. If someone has a similar problem here my workaround to solve the problem. The goal is to compare an line in a sql Create Table Statement with the actually value in the Database ?php $str = '`hereIsDefaultNULL` int(255) default NULL'; 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) { $fieldRow['Default'] = 'NULL'; } $strToCompare= '`' . $fieldRow['Field'] . '` ' . $fieldRow['Type'] . ' default ' . $fieldRow['Default']; if ($str == $strToCompare) { echo 'OK'; } } ? Previous Comments: [2009-11-12 10:43:49] j...@php.net But in PHP ('' == NULL) is true and ('' === NULL) isn't. :) [2009-11-12 10:27:50] w at lder dot de Here the var_dump: array(6) { [Field]= string(17) hereIsDefaultNULL [Type]= string(8) int(255) [Null]= string(3) YES [Key]= string(0) [Default]= NULL [Extra]= string(0) } array(6) { [Field]= string(19) defaultEmptyvarchar [Type]= string(12) varchar(255) [Null]= string(2) NO [Key]= string(0) [Default]= string(0) [Extra]= string(0) } Yes, I know that '' == NULL (true), but in mySQL : mysql SELECT '' IS NULL; ++ | '' IS NULL | ++ | 0 | ++ mysql SELECT NULL IS NULL; +--+ | NULL IS NULL | +--+ |1 | +--+ [2009-11-12 10:06:28] u...@php.net 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 [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. 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=50147edit=1
#50147 [NEW]: DEFAULT NULL Values in mysql_query('SHOW COLUMNS FROM `xx`');
From: w at lder dot de Operating system: Linux 2.6.16.21-0.25-default PHP version: 5.2.11 PHP Bug Type: MySQL related Bug description: DEFAULT NULL Values in mysql_query('SHOW COLUMNS FROM `xx`'); Description: The attached Code results a wrong result. MySQL: Server Version: 5.0.26 MySQL-Client-Version: 5.0.26 Reproduce code: --- ?php /* MySQL: CREATE TABLE IF NOT EXISTS `test` ( `hereIsDefaultNULL` int(255) default NULL, `defaultNULLvarchar` varchar(255) default NULL ) */ mysql_connect('localhost','user',''); mysql_select_db('test'); $columns_res = mysql_query('SHOW COLUMNS FROM `test`'); while ($fieldRow = mysql_fetch_assoc($columns_res)) { print_r($fieldRow) ; } ? Expected result: Array ( [Field] = hereIsDefaultNULL [Type] = int(255) [Null] = YES [Key] = [Default] = NULL [Extra] = ) Array ( [Field] = defaultNULLvarchar [Type] = varchar(255) [Null] = YES [Key] = [Default] = NULL [Extra] = ) Actual result: -- Array ( [Field] = hereIsDefaultNULL [Type] = int(255) [Null] = YES [Key] = [Default] = [Extra] = ) Array ( [Field] = defaultNULLvarchar [Type] = varchar(255) [Null] = YES [Key] = [Default] = [Extra] = ) -- Edit bug report at http://bugs.php.net/?id=50147edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=50147r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=50147r=trysnapshot53 Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=50147r=trysnapshot60 Fixed in SVN: http://bugs.php.net/fix.php?id=50147r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=50147r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=50147r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=50147r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=50147r=needscript Try newer version: http://bugs.php.net/fix.php?id=50147r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=50147r=support Expected behavior: http://bugs.php.net/fix.php?id=50147r=notwrong Not enough info: http://bugs.php.net/fix.php?id=50147r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=50147r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=50147r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=50147r=php4 Daylight Savings:http://bugs.php.net/fix.php?id=50147r=dst IIS Stability: http://bugs.php.net/fix.php?id=50147r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=50147r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=50147r=float No Zend Extensions: http://bugs.php.net/fix.php?id=50147r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=50147r=mysqlcfg
#50147 [Com]: DEFAULT NULL Values in mysql_query('SHOW COLUMNS FROM `xx`');
ID: 50147 Comment by: w at lder dot de Reported By: w at lder dot de Status: Feedback Bug Type: MySQL related Operating System: Linux 2.6.16.21-0.25-default PHP Version: 5.2.11 New Comment: 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| | ++--+--+-+-+---+ Previous Comments: [2009-11-11 10:44:06] u...@php.net ext/mysql returns whatever MySQL delivers. Please verify that the MySQL prompt returns the result you want. If not, this is a MySQL bug not a PHP bug. Please run on the command line: mysql -uuser -ppassword database... mysql SHOW COLUMNS FROM mytable [2009-11-11 10:35:02] w at lder dot de Description: The attached Code results a wrong result. MySQL: Server Version: 5.0.26 MySQL-Client-Version: 5.0.26 Reproduce code: --- ?php /* MySQL: CREATE TABLE IF NOT EXISTS `test` ( `hereIsDefaultNULL` int(255) default NULL, `defaultNULLvarchar` varchar(255) default NULL ) */ mysql_connect('localhost','user',''); mysql_select_db('test'); $columns_res = mysql_query('SHOW COLUMNS FROM `test`'); while ($fieldRow = mysql_fetch_assoc($columns_res)) { print_r($fieldRow) ; } ? Expected result: Array ( [Field] = hereIsDefaultNULL [Type] = int(255) [Null] = YES [Key] = [Default] = NULL [Extra] = ) Array ( [Field] = defaultNULLvarchar [Type] = varchar(255) [Null] = YES [Key] = [Default] = NULL [Extra] = ) Actual result: -- Array ( [Field] = hereIsDefaultNULL [Type] = int(255) [Null] = YES [Key] = [Default] = [Extra] = ) Array ( [Field] = defaultNULLvarchar [Type] = varchar(255) [Null] = YES [Key] = [Default] = [Extra] = ) -- Edit this bug report at http://bugs.php.net/?id=50147edit=1