Ok, I did a little tweaking of my own, but I'm not an SQL guru, so please let me know why/if this is wrong.
This is the bit of code that CodeJunkie, so generously provided to be placed in the memberlist.php (including the original sql statement):
Code: Select all
if(isset($sort_key_sql['y'])) {
$sql = "SELECT u.user_id
FROM " . USERS_TABLE . " u
$sql_from
LEFT JOIN " . PROFILE_FIELDS_DATA_TABLE . " fd ON (u.user_id = fd.user_id)
WHERE u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ")
$sql_where
ORDER BY $order_by";
} else {
$sql = "SELECT u.user_id
FROM " . USERS_TABLE . " u
$sql_from
WHERE u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ")
$sql_where
ORDER BY $order_by";
}
This is generally great, but I needed a way to make more than one user column orderable. So what I did was to put the "LEFT JOIN" line directly into to original sql statement like this:
Code: Select all
$sql = "SELECT u.user_id
FROM " . USERS_TABLE . " u
$sql_from
LEFT JOIN " . PROFILE_FIELDS_DATA_TABLE . " fd ON (u.user_id = fd.user_id)
WHERE u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ")
$sql_where
ORDER BY $order_by";
Now, obviously that's a more lean way of doing it, but is it right? I mean, to me it seems to work like a charm, but I might be missing something. Or I might be brilliant
Please let me know.