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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
9 + 37 = ?
Subscribe to this entry?

 
 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2019 The PHP Group
All rights reserved.
Last updated: Sat Dec 14 05:01:23 2019 UTC