PDA

View Full Version : Order by?


SilverDragonTears
04-20-2012, 12:06 AM
How do I order this by itemname? I still don't quite understand the new coding :/


$stmt = $GLOBALS['adopts']->select("items", array(), "shop ='{$this->shopname}'");

Hall of Famer
04-20-2012, 04:26 AM
Well just pass ORDER BY to the whereclause, if you have a whereclause. Incase you do not have a whereclause(and thus selecting all rows), you can do the following:


$stmt = $GLOBALS['adopts']->select("items", array(), "1 ordered by itemname");


It may look a bit funny, but the magical keyword '1' does the trick for ya.

SilverDragonTears
05-02-2012, 12:24 AM
This isn't ordering by cost...

$stmt = $adopts->join("adoptables_conditions", "adoptables_conditions.id = adoptables.id")
->select("adoptables", array(), "breed = 'short'", "1 ordered by cost ASC");

fadillzzz
05-02-2012, 05:28 AM
@Silver Kitsune
Yeah sorry about that. The new release will include a much better database class. Although I won't say that it's comprehensive or anything, but it should suffice for most of the needed queries.

But anyway, the right keyword is ORDER BY not ORDERED BY.

Hall of Famer
05-02-2012, 10:51 PM
Oh my goodness, made a typo in that php code I wrote. Didnt realize that since I did say 'ORDER BY' at the beginning of my post, did I? XD