Re: PDO question: any way to resolve duplicate column names with PDO_FETCH_ASSOC?
| From: | Greg Beaver | Date: | Thu, 19 May 2005 15:02:26 +0000 |
| Subject: | Re: PDO question: any way to resolve duplicate column names with PDO_FETCH_ASSOC? | ||
| References: | 1 | Groups: | php.pecl.dev |
| Request: | Send a blank email to pecl-dev+get-2373@lists.php.net to get a copy of this message | ||
Matthew Peters wrote:
I really like the PDO_FETCH_ASSOC behaviour where I get back an associative array indexed by column name, but I have a problem when there are two columns with the same name in the result set: for example when I join two tables that both contain a column called 'id', or 'name', for example. Experiment shows that one of them hides the other. I would really like it there a way to get both back and to know which was from which table. The simplest solution to my mind would be if there were a way to get the keys in the associative array to be qualified with table name: 'table1.id' and 'table2.id', for example. Does anyone know of a way of doing this or something similar?try SELECT table1.id as table1_id, table2.id as table2_id, table1.*, table2.* in your sql query (nothing to do with PDO, in other words) Greg