From:             marques at displague dot com
Operating system: 
PHP version:      5.2.6
PHP Bug Type:     PDO related
Bug description:  getColumnMeta returns 'LONG','VAR_STRING','BLOB' as php 
native_type

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
)


-- 
Edit bug report at http://bugs.php.net/?id=46508&edit=1
-- 
Try a CVS snapshot (PHP 5.2):        
http://bugs.php.net/fix.php?id=46508&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):        
http://bugs.php.net/fix.php?id=46508&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):        
http://bugs.php.net/fix.php?id=46508&r=trysnapshot60
Fixed in CVS:                        
http://bugs.php.net/fix.php?id=46508&r=fixedcvs
Fixed in CVS and need be documented: 
http://bugs.php.net/fix.php?id=46508&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=46508&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=46508&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=46508&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=46508&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=46508&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=46508&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=46508&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=46508&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=46508&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=46508&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=46508&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=46508&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=46508&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=46508&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=46508&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=46508&r=mysqlcfg

Reply via email to