I have several table with similar column name in my database.
Let say TABLE 1, TABLE 2, TABLE 3 have a column named : "name". Those are not indexed columns. They contain different and independant data.
If I run a query joining these 3 tables and fetchAll() the results, there will be only one "name" entry in the resulting array since fetchAll() overwrite the column with the same name.
The regular MySQL Library let you access such results doing:
mysql_result($result,0,'TABLE1.name');
How can I let PDO append the table name before the column name like : TABLE1.name, TABLE2.name, etc.
I want to AVOID using alias in my SQL query since I have tons of tables. The only answers I found online uses alias. Is there any parameters we can feed to PDO to do what I am looking for?
PDO::FETCH_NUM
& use the number of the column, orFETCH_BOUND
with->bindColumn()
, again with the number based index. – Wrikkenvar_dump()
-ing the results of->fetchAll(PDO::FETCH_NUM)
& examining it's output will probably tell you enough to work with it. – WrikkenPDO::FETCH_NAMED
. – marver