ID:          46508
 Updated by:  [EMAIL PROTECTED]
 Reported By: marques at displague dot com
 Status:      Assigned
 Bug Type:    PDO related
 PHP Version: 5.2.6
 Assigned To: mysql
 New Comment:

Hi Marques, good observation! I've updated the patch. ;)

Thanks.


Previous Comments:
------------------------------------------------------------------------

[2008-11-07 16:02:59] marques at displague dot com

The values that are currently being reported may belong in the
getmetacolumn array member 'driver:decl_type' (per the getColumnMeta
documentation example).

------------------------------------------------------------------------

[2008-11-07 15:49:25] [EMAIL PROTECTED]

Patch: http://felipe.ath.cx/diff/bug46508.diff (5.3)

------------------------------------------------------------------------

[2008-11-06 15:05:57] marques at displague dot com

I put my expected and actual results in the wrong boxes.

The capitalized native_types are not what I would expect because they
are not php native types per the PHP documentation on types and the
getColumnMeta example.

------------------------------------------------------------------------

[2008-11-06 15:02:20] 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
)



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=46508&edit=1

Reply via email to