MyBB Community Forums

Full Version: Simple Select and Order by 2 Columns (MyBB Database Class)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm trying to select all teams in the league and order them by their wins, and then by their amount of ties. It's only letting me put in 1 order clause.. any help?

This is what I currently have that orders by JUST wins.. the column for ties is 'record_ties'.


$db->simple_select("teams", "*", "`league` = '".$db->escape_string($_GET[id])."'", array("order_by" => "record_wins", "order_dir" => "DESC"));
You can just pass it in as a string.

$db->simple_select("teams", "*", "`league` = '".$db->escape_string($_GET[id])."'", array("order_by" => "record_wins DESC, record_ties DESC"));

Also, I'd change:




All POST and GET data is available in $mybb->input, some common parameters are pre-sanitised too. Using $_POST and $_GET directly is kinda messy, just make sure you've globalised $mybb in your function.

Happy Friday! Smile