0

I'm using PDO's fetch to return data from two tables (orders and order_items).

The issue is I would like all the order_item row data to be nested as arrays inside each order data row.

Whilst looping through the rows is it possible to do the following?

$variable = $row[tablename.columnname]

I've tried this with and without specifying an alias for in my query (SELECT * FROM orders as orders WHERE ...etc..) and I'm getting an 'Notice: Undefined index:' error. Any ideas?

EDIT - THIS QUESTION IS DIFFERENT

Sharklazer
  • 41
  • 5
  • 1
    How about trying it out? ;-) – Eel Lee Apr 29 '15 at 12:59
  • 1
    no, they will come back with just the column names. if you want it to come back that way then you need to alias each of the column names. – Jonathan Apr 29 '15 at 13:02
  • once its fetched, it will overwrite that column if there's collision. thats why you alias your columns – Kevin Apr 29 '15 at 13:04
  • I've tried this with and without specifying an alias for in my query (SELECT * FROM orders as orders WHERE ...etc..) and I'm getting an 'Notice: Undefined index:' error. Any ideas? – Sharklazer Apr 29 '15 at 13:12

0 Answers0