PDO include table name prefixes in FETCH_ASSOC
| From: | Aaron Paetznick | Date: | Wed, 24 Mar 2010 16:05:55 +0000 |
| Subject: | PDO include table name prefixes in FETCH_ASSOC | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-47003@lists.php.net to get a copy of this message | ||
Many of my MySQL tables have columns with the same name. I want to have PDO include table names in named result sets. For example:
$sth = $dbh->prepare("SELECT * FROM table0, table1");
$result = $sth->fetchAll(PDO::FETCH_ASSOC);
I want $result to be organized like:
echo $result["table0.column0"];
echo $result["table0.column1"];
echo $result["table1.column0"];
echo $result["table1.column1"];
Or, alternatively:
echo $result["table0"]["column0"];
echo $result["table0"]["column1"];
echo $result["table1"]["column0"];
echo $result["table1"]["column1"];
Any ideas? Thanks!
--Aaron