I’ve hit a wall trying to get MDB2 to give me the results of my database query in the format I want. I’m probably misunderstanding something about MDB2, so please enlighten me.
The SQL below, when executed from a MySQL command line, returns what I want:
First Building Name
Second Building Name
Third Building Name
Forth Building Name
… so I know it’s not the SQL causing the problem.
Now the MDB2 code:
$sql = 'SELECT DISTINCT Property FROM Table1 INNER JOIN Table2 ON Table1.Id=Table2.Table1Id ORDER BY Property ASC'; $result = $mdb2->query($sql); errorCheck($result); // Check that result is not an error. $data = $result->fetchAll(MDB2_FETCHMODE_ORDERED); // Gives an array of all rows at once. $result->free(); // Free all memory associated with queries. print_r($data);
MDB2 returns the data in this format:
Array (  => Array (  => First Building Name )  => Array (  => Second Building Name )  => Array (  => Third Building Name )  => Array (  => Forth Building Name ) )
I want the data in this format instead:
Array (  => First Building Name  => Second Building Name  => Third Building Name  => Forth Building Name )