Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Not Solved Simple Select and Order by 2 Columns (MyBB Database Class)
#1
Not Solved
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'.

Thanks![/php]

$db->simple_select("teams", "*", "`league` = '".$db->escape_string($_GET[id])."'", array("order_by" => "record_wins", "order_dir" => "DESC"));
#2
Not Solved
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:

$db->escape_string($_GET[id])

to:

intval($mybb->input['id'])

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
MyReactions - All Plugins

Can you still feel the butterflies?

Free never tasted like pudding.


Forum Jump:


Users browsing this thread: 1 Guest(s)