著者とともに joomla の記事を取得するための SQL リクエストを作成しました。
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;
}
それは魅力のように機能しますが、別のブラウザーから同じユーザーにログインすると、すべてのコンテンツが 2 回複製され、3 回目にログインするとすべてのコンテンツが 3 回複製されるという奇妙な部分があります。私が見る限り、問題は次の行にあります。
LEFT JOIN #__session AS ss ON ss.userid = u.id AND ss.userid > 0 AND ss.guest = 0
助言がありますか?