I was looking at the results of a mysql join in phpmyadmin, and comparing it to the php print_r dump, and noticed that the print_r seems to only use the first (row)"id" variable it comes to, and skips the second one. Is there a reason why the print_r wouldn't put something like a 'tablename."id"' instead of just eliminating the second tables "id" value?
PHPmyADMIN head dump:
PHP sample dump:
print_r
just prints the array as it is, and apparently it only has those 4 indexes with the specified values.
The problem is in the query itself. Table names or table aliases are not returned in the field name, so you get two fields named id
. Since an array cannot have the same key twice, one of the two is just skipped.
So to solve it, change the query by specifying an alias for the field itself:
SELECT
t1.id as t1_id, -- Key will be t1_id
t2.id as t2_id, -- Key will be t2_id
.. other fields ..
FROM
.. etcetera ...