|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-05-22 16:57 UTC] ulf dot wendel at phpdoc dot de
[2008-07-22 10:42 UTC] uwendel at mysql dot com
[2009-11-05 07:55 UTC] ulf dot wendel at phpdoc dot de
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 02:00:01 2025 UTC |
Description: ------------ I've attached a patch that adds support for the fetch table name attribute to the PDO MySQL driver. This could be very helpful when building multiple data objects off subsets of the same query (i.e., one per table). Reproduce code: --------------- <?php $db = new PDO('mysql:host=localhost;dbname=test', 'root', ''); $db->setAttribute(PDO::ATTR_FETCH_TABLE_NAMES, 1); $rows = $db->query('SELECT * FROM test LIMIT 1')->fetchAll(PDO::FETCH_ASSOC); var_dump($rows); ?> Patch is available from: http://dothedrew.net/misc/pdo_mysql-fetch_tables.patch Expected result: ---------------- array(1) { [0]=> array(2) { ["test.name"]=> string(6) "Andrew" ["test.id"]=> string(1) "1" } } Actual result: -------------- array(1) { [0]=> array(2) { ["name"]=> string(6) "Andrew" ["id"]=> string(1) "1" } }