Edit report at https://bugs.php.net/bug.php?id=46508&edit=1
ID: 46508 Updated by: johan...@php.net Reported by: marques at displague dot com Summary: [PATCH]: getColumnMeta returns 'LONG','VAR_STRING','BLOB' as php native_type Status: Assigned Type: Bug Package: PDO related Operating System: * PHP Version: 5.2.9 -Assigned To: mysql +Assigned To: Block user comment: N Private report: N New Comment: The complete topic is more complex and needs a more specific specification. I agree to the fact that long is no good choice. For the MySQL case mind that, if PDO is using emulation of prepared statements, which it does by default all data is returned as string, as that's the way it comes over the wire. when using native prepared statements the type used might change within a column (use a column with an integer type larger than PHP_INT_MAX, then values in PHP's integer/long range might be returned as PHP int/long (depends a bit on other factors, i.e. mysqlnd vs libmysql) else as string. So unless we define this for all drivers properly we (MySQL) will not change the behavior. Previous Comments: ------------------------------------------------------------------------ [2010-05-11 13:13:46] u...@php.net Whatever the docs say, what counts is "EXPERIMENTAL" = "TENTATIVE" = "UNDEFINED". It is irrelevant how meaningful and sensible your suggestion is. If you want any changes to PDO, please write an RFC/discuss on internal/do whatever the current procedure is to get the "EXPERIMENTAL" removed. Specification via bug reports does not make much sense to me. You fix one and break another causing a bug report stating just the opposite and, for example, claiming you break backwards compatibility. The underlying issue is the lack of a clear definition. The issue is the "EXPERIMENTAL". I do understand how annoying the answer is. But please respect that "specification via bug reports" is not a good approach and sometimes it is better to go a step back and do it right: fix PDO as such. Whoever wants, may play the patch-and-work-without-specs game. But I won't do it. Its an endless game leading nowhere: leaving bug open, unassigning mysql (at least as long as there is no clear specs). ------------------------------------------------------------------------ [2009-06-29 10:18:50] marques at displague dot com I stated in the bug report that the return values do not match up with the documentation. The docs state (pretty clearly): http://php.net/manual/en/pdostatement.getcolumnmeta.php: native_type The PHP native type used to represent the column value. driver:decl_type The SQL type used to represent the column value in the database. If the column in the result set is the result of a function, this value is not returned by PDOStatement::getColumnMeta(). pdo_type The type of this column as represented by the PDO::PARAM_* constants. The problems are that (per the docs) native_type is missed for some types (TINYINT) and that the native_type values currently returned should be in driver:decl_type, and PHP native types should be returned for native_type instead. ------------------------------------------------------------------------ [2009-06-29 09:42:27] uwendel at mysql dot com Why would I bother about a function that has no specification? Without a specification there is no definition of how things should go and there is no bug - by definition... "Warning This function is EXPERIMENTAL. The behaviour of this function, its name, and surrounding documentation may change without notice in a future release of PHP. This function should be used at your own risk. ", http://de.php.net/manual/en/pdostatement.getcolumnmeta.php There needs to be a proper PDO spec before one can decide about any bug report. IMHO the bug report should be closed as bogus. ------------------------------------------------------------------------ [2009-04-10 14:01:57] php at displague dot com 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? ------------------------------------------------------------------------ [2008-11-07 16:24:52] fel...@php.net Hi Marques, good observation! I've updated the patch. ;) Thanks. ------------------------------------------------------------------------ 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 https://bugs.php.net/bug.php?id=46508 -- Edit this bug report at https://bugs.php.net/bug.php?id=46508&edit=1