php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46533 PDOStatement::getColumnMeta lacks some information regarding aliases
Submitted: 2008-11-10 10:09 UTC Modified: 2008-11-17 17:32 UTC
Votes:3
Avg. Score:4.7 ± 0.5
Reproduced:3 of 3 (100.0%)
Same Version:1 (33.3%)
Same OS:1 (33.3%)
From: taco at procurios dot nl Assigned: mysql (profile)
Status: Wont fix Package: PDO related
PHP Version: 5.2.6 OS: Linux
Private report: No CVE-ID: None
 [2008-11-10 10:09 UTC] taco at procurios dot nl
Description:
------------
When using aliases for tables and/or columns in a MySQL query. The method PDOStatement::getColumnMeta() will not tell you anything about the original table / column name. In the MySQLi extension the information about the original table / column name was represented as 'orgtable' and 'orgname' this would be a very nice addition to the PDO extension.

Reproduce code:
---------------
SQL:
CREATE TABLE `foobar` (
  `bar` varchar(255) default NULL
) ENGINE=MEMORY;

PHP:
print_r(
  $PDO->query("SELECT foo.bar as baz FROM foobar foo")
      ->getColumnMeta(0)
);

Expected result:
----------------
Array
(
    [native_type] => VAR_STRING
    [flags] => Array
        (
        )

    [table] => foo
    [orgtable] => foobar
    [name] => baz
    [orgname] => bar
    [len] => 255
    [precision] => 0
    [pdo_type] => 2
)

Actual result:
--------------
Array
(
    [native_type] => VAR_STRING
    [flags] => Array
        (
        )

    [table] => foo
    [name] => baz
    [len] => 255
    [precision] => 0
    [pdo_type] => 2
)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-11-17 17:32 UTC] johannes@php.net
This won't be fixed till we get a PDO2 (or whatever there will be in future) as there is no specification about naming of custom elements. Adding them randomly in one driver isn't good for an "abstraction layer".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Oct 25 12:01:27 2024 UTC