I am using ADODB to connect to a database and query multiple tables with a single select statement. The problem is that in the two tables (Users and Groups) I am selecting from contain the same field name called 'id', and I am using an associative array fetch mode (i.e. $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC). The problem I am experiencing is that I am unable to use $result->fields['users.id'] to obtain the ID from the Users table instead of the Groups table.
Here is the code:
The problem here is that echo $results->fields['id'] returns the ID for the Groups table, and echo $results->fields['users.id'] returns an "undefined index on users.id" error. I've searched through the ADODB manual and the web for a solution, but can only seem to find a way to do this using a fetch mode of "ADODB_FETCH_NUM". Does anybody have any idea how to do this using ADODB_FETCH_ASSOC mode?
$sql = "select * from users, groups";
$dbConn = ADONewConnection('mysqlt');
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
$dbConn->Connect("db1", "root", "root", "nat");
$results = $dbConn->Execute($sql);