[wp-hackers] wp_list_authors and DB queries

Computer Guru computerguru at neosmart.net
Thu Nov 22 03:42:00 GMT 2007


It seems what goes around, comes around <G>
http://groups.google.com/group/wp-hackers/browse_thread/thread/f0a31b05a558d45f/1e1e1b3947442ceb

I had that issue just yesterday (or was it the day before?)

Anyway, solution is to use an aggregate function in the ORDER BY syntax or
use subqueries.


On 11/22/07, Bob <wp-hackers at nj-arp.org> wrote:
>
> > Couldnt you just add
> > ORDER BY display_name
> > to the SQL Query?
>
> No.  I tried.  It seems the GROUP BY is doing a sort, so you can't tell it
> to sort via ORDER BY.
>
> It did give me a pretty SQL error message in my sidebar, however.  ;-)
>
>
>
> ----- Original Message -----
> From: "DD32" <wordpress at dd32.id.au>
> To: <wp-hackers at lists.automattic.com>
> Sent: Wednesday, November 21, 2007 10:22 PM
> Subject: Re: [wp-hackers] wp_list_authors and DB queries
>
>
> > Couldnt you just add
> > ORDER BY display_name
> > to the SQL Query?
> >
> > On Thu, 22 Nov 2007 14:19:59 +1100, Bob <wp-hackers at nj-arp.org> wrote:
> >
> >> OK, I threw in a sort of the array.  Here's the user-defined function
> to
> >> do
> >> the comparison:
> >>
> >> function wp_widget_authors_cmp($a, $b) {
> >>         $al = strtolower($a->display_name);
> >>         $bl = strtolower($b->display_name);
> >>         if ($al == $bl) {
> >>                 return 0;
> >>         }
> >>         return ($al < $bl) ? -1 : 1;
> >> }
> >>
> >>
> >> And the call to usort just before the foreach ($authors as $author):
> >>
> >> usort($authors, "wp_widget_authors_cmp");
> >>
>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>



-- 
Computer Guru
Director,
NeoSmart Technologies
http://neosmart.net/blog/


More information about the wp-hackers mailing list