Thanks for the idea of using a union. I'm not sure why I hadn't tried that. I cleaned things up tremendously. I'm now getting the data in a single query and doing the sorting as part of the query.
Thanks, Chris, for reminding me about the trick to create a temporary sort value with IF(). On 4 Jun 2013, at 9:29, Steve Meyers <[email protected]> wrote: > On 6/4/13 8:11 AM, Wade Shearer wrote: >> The reason that I can't do the sort in the SQL is because I am make >> four queries and then merging them first. > > Can't you do a UNION, and then sort that? If you post (or send me) your four > queries, I can show you how to do it all in a single query including the sort. > > If you really want to do it in the PHP code, I'd try this: > > usort($all, function($a, $b) { > $a_sort = ($a['type'] == 3 ? 6 : intval($a['type'])); > $b_sort = ($b['type'] == 3 ? 6 : intval($b['type'])); > if ($a_sort == $b_sort) return 0; > return ($a_sort < $b_sort) ? -1 : 1; > } _______________________________________________ UPHPU mailing list [email protected] http://uphpu.org/mailman/listinfo/uphpu IRC: #uphpu on irc.freenode.net
