我编写了 sql 请求来检索 joomla 文章以及作者:
static function getLists(&$params)
{
$db = JFactory::getDbo();
$lists = null;
$query = "SELECT cc.title AS category, a.id, a.title, a.created as created, av.add_image as imgthrumb, ua.avatar as avatar, ar.intotext as introtext, ss.userid as onlineid,
u.id AS userlink, u.username as username, u.lastvisitDate as lastvisit, a.hits, cc.id as catid, a.state as state, a.created_by as authorid, mp.group_id as groupid, ug.title as ugtitle
FROM #__content AS a
LEFT JOIN #__categories AS cc ON a.catid = cc.id
LEFT JOIN #__users AS u ON u.id = a.created_by
LEFT JOIN #__cck_store_item_content AS av ON av.id = a.id
LEFT JOIN #__comprofiler AS ua ON user_id = a.created_by
LEFT JOIN #__cck_store_item_cck_store_item_content AS ar ON ar.id = a.id
LEFT JOIN #__user_usergroup_map AS mp ON mp.user_id = a.created_by
LEFT JOIN #__usergroups AS ug ON ug.id = mp.group_id
LEFT JOIN #__session AS ss ON ss.userid = u.id AND ss.userid > 0 AND ss.guest = 0
WHERE a.created_by = u.id AND a.id >0
AND DATE(a.created) >= DATE_SUB(CURRENT_DATE, INTERVAL ".(int)$safe_date." DAY) AND a.access = 1 AND a.state = 1 AND a.created > 0
ORDER BY created desc";
$db->setQuery($query,0,10);
$lists = $db->loadObjectList();
return $lists;
}
它就像一个魅力,但这里有一些奇怪的部分,如果我从不同的浏览器登录同一个用户,它会复制我的所有内容两次,如果我第三次登录,它会复制所有内容 3 次,依此类推!据我所知,问题出在这一行:
LEFT JOIN #__session AS ss ON ss.userid = u.id AND ss.userid > 0 AND ss.guest = 0
有什么建议么?