|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2008-11-06 15:02 UTC] marques at displague dot com
Description: ------------ Using the pdo_mysql driver, when I do a getColumnMeta on an int(11) NULL field, the native_type returned is 'LONG'. I expect 'integer'. Also, the pdo_type returned on this column is PDO::PARAM_STR, not PDO::PARAM_INT as I would expect. http://php.net/manual/en/pdostatement.getcolumnmeta.php defines native_type as "The PHP native type used to represent the column value.". The example on that page shows a return value of 'integer'.. This would seem to mesh with the PHP types defined here: http://php.net/manual/en/function.gettype.php If this is just a documentation bug due to recent changes, perhaps someone should consider leaving native_type intact as php native type, and using 'type' or something for these new values. Reproduce code: --------------- // MySQL: create table `table` (`i` int default null, `s` varchar(32), `b` text, `t` timestamp, `d` datetime); $pdo= new PDO("mysql:host=localhost;dbname=somedb","user","pass"); $stmt=$pdo->query("SELECT * from `table` limit 0"); for($i=0;$i<5;$i++) print_r($stmt->getColumnMeta($i)); Expected result: ---------------- Array ( [native_type] => LONG [flags] => Array ( ) [table] => table [name] => i [len] => 11 [precision] => 0 [pdo_type] => 1 ) Array ( [native_type] => VAR_STRING [flags] => Array ( ) [table] => table [name] => s [len] => 32 [precision] => 0 [pdo_type] => 2 ) Array ( [native_type] => BLOB [flags] => Array ( [0] => blob ) [table] => table [name] => b [len] => 65535 [precision] => 0 [pdo_type] => 2 ) Array ( [native_type] => TIMESTAMP [flags] => Array ( [0] => not_null ) [table] => table [name] => t [len] => 19 [precision] => 0 [pdo_type] => 2 ) Array ( [native_type] => DATETIME [flags] => Array ( ) [table] => table [name] => d [len] => 19 [precision] => 0 [pdo_type] => 2 ) Actual result: -------------- Array ( [native_type] => integer [flags] => Array ( ) [table] => table [name] => i [len] => 11 [precision] => 0 [pdo_type] => 1 ) Array ( [native_type] => string [flags] => Array ( ) [table] => table [name] => s [len] => 32 [precision] => 0 [pdo_type] => 2 ) Array ( [native_type] => string [flags] => Array ( [0] => blob ) [table] => table [name] => b [len] => 65535 [precision] => 0 [pdo_type] => 2 ) Array ( [native_type] => string [flags] => Array ( [0] => not_null ) [table] => table [name] => t [len] => 19 [precision] => 0 [pdo_type] => 2 ) Array ( [native_type] => string [flags] => Array ( ) [table] => table [name] => d [len] => 19 [precision] => 0 [pdo_type] => 2 ) PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 20:00:01 2025 UTC |
This should probably be the topic of another bug, but TINYINT doesn't return a native_type (I'm guessing because TINY is used everywhere, but not TINYINT - maybe another constant is needed). mysql://user@host/db> show columns from table like 'disable' \G; *************************** 1. row *************************** Field: disable Type: tinyint(4) Null: NO Key: Default: 0 Extra: 1 row in set (0.00 sec) getColumnMeta (php 5.2.9) returns: Array ( [flags] => Array ( [0] => not_null ) [table] => promo_item [name] => disable [len] => 4 [precision] => 0 [pdo_type] => 2 ) native_type is missing. Is there any chance this correction will make it into 5.2.x?