ORDER BY is returning too many results
Posted: Sat Apr 05, 2008 2:34 am
This has been driving me nuts. I'm fairly new to PHP so if I'm doing this completely wrong let me know.
Whenever I query a SQLite database using an order by clause the returned array seems to combine the database columns. The first column contains the contents of each column, the second column contains the contents of each column except the first, the third column contain the contents of each column except the first and second, and so on.
Example database:
Then the query:
Returns:
Array ( [0] => Array ( [model] => CaymanPorscheGermany [make] => PorscheGermany [country] => Germany ) )
If I leave out the order by clause it works fine:
Array ( [0] => Array ( [model] => Cayman [make] => Porsche [country] => Germany ) )
What am I missing here?
Thanks in advance.
Whenever I query a SQLite database using an order by clause the returned array seems to combine the database columns. The first column contains the contents of each column, the second column contains the contents of each column except the first, the third column contain the contents of each column except the first and second, and so on.
Example database:
Code: Select all
Model Make Country
Cayman Porsche Germany
Elise Lotus EnglandCode: Select all
$db = new SQLiteDatabase("example.sdb");
$result_array = $db->arrayQuery("SELECT * FROM cars ORDER BY model LIMIT 1",SQLITE_ASSOC);
print_r($result_array); Array ( [0] => Array ( [model] => CaymanPorscheGermany [make] => PorscheGermany [country] => Germany ) )
If I leave out the order by clause it works fine:
Array ( [0] => Array ( [model] => Cayman [make] => Porsche [country] => Germany ) )
What am I missing here?
Thanks in advance.