我正在使用此插件
http://mods.mybb.com/download/online-today-1.2.2
以下部分是查询
$queries[] = $db->simple_select(
"users u LEFT JOIN ".TABLE_PREFIX."sessions s ON (u.uid=s.uid)",
"s.sid, s.ip, s.time, s.location, u.uid, u.username, u.invisible, u.usergroup, u.displaygroup",
"u.lastactive > $timesearch ORDER BY u.username ASC, s.time DESC"
);
$queries[] = $db->simple_select(
"sessions s LEFT JOIN ".TABLE_PREFIX."users u ON (s.uid=u.uid)",
"s.sid, s.ip, s.uid, s.time, s.location, u.username, u.invisible, u.usergroup, u.displaygroup",
"s.time>'$timesearch' ORDER BY u.username ASC, s.time DESC"
);
现在,我想修改此查询,以获取大于0后计数的用户。因此,至少1个及以上
谢谢
php,mybb
尝试以下代码:
$queries[] = $db->simple_select(
"users u LEFT JOIN ".TABLE_PREFIX."sessions s ON (u.uid=s.uid)",
"s.sid, s.ip, s.time, s.location, u.uid, u.username, u.invisible, u.usergroup, u.displaygroup",
"u.lastactive > $timesearch AND u.postnum > 0 ORDER BY u.username ASC, s.time DESC"
);
$queries[] = $db->simple_select(
"sessions s LEFT JOIN ".TABLE_PREFIX."users u ON (s.uid=u.uid)",
"s.sid, s.ip, s.uid, s.time, s.location, u.username, u.invisible, u.usergroup, u.displaygroup",
"s.time>'$timesearch' AND u.postnum > 0 ORDER BY u.username ASC, s.time DESC"
);
我刚刚添加了一个额外的WHERE
子句,该子句检查postnum
字段以确保其大于0。