title: Get PHP MySQL PDO column table name as a result of a join
body: <p>I have fields that have the same name in different tables that I'm joining. Such as <code>ticket.status</code>, <code>user.status</code> and <code>transaction.status</code>. At the moment the query returns just <code>status</code>.</p>
  
  <p>How can I get the table name in such a way that it stops similar field names from overwriting and so I can tell the difference between the fields.</p>
  
  <p>Simply put:</p>
  
  <pre><code>$data = array($eventId);
  $statement = $this-&gt;db-&gt;prepare("SELECT * FROM ticket, user, transaction 
                          WHERE ticket.eventId = ? 
                          AND ticket.userId = user.userId
                          AND ticket.transactionId = transaction.transactionId");
  
  $statement-&gt;execute($data); 
  $rows = $statement-&gt;fetchAll(PDO::FETCH_ASSOC);
  </code></pre>
  
  <p>In my research I've found the constant <code>PDO::ATTR_FETCH_TABLE_NAMES</code> that looks like it could help, but I do not know how to implement ( I assume through <code>$statement-&gt;setAttribute();</code> somehow). </p>
  
  <p>I also have concerns that it will not work, as the PHP documentation mentions it is dependent on the driver.</p>
  
  <p>Thanks</p>