Друзья онлайн есть а все друзья нет
function usrFriends($user_id, &$total, $perpage=10, $page=1){ }
$usr = $model->getUserShort($id); if (!$usr) { cmsCore::error404(); } $page = $inCore->request('page', 'int', 1); $perpage = 10; $friends = usrFriends($usr['id'], $total, $perpage, $page);
$sql = "SELECT CASE WHEN f.from_id = $user_id THEN f.to_id WHEN f.to_id = $user_id THEN f.from_id END AS id_friends, u.id as id, u.nickname as nickname, u.login as login, u.is_deleted as is_deleted, u.status, p.imageurl as avatar, u.logdate as flogdate, o.id as online FROM cms_user_friends f LEFT JOIN cms_users u ON u.id = CASE WHEN f.from_id = $user_id THEN f.to_id WHEN f.to_id = $user_id THEN f.from_id END LEFT JOIN cms_user_profiles p ON p.user_id = u.id LEFT JOIN cms_online o ON p.user_id = o.user_id WHERE (from_id = '$user_id' OR to_id = '$user_id') AND is_accepted =1 LIMIT ".(($page-1)*$perpage).", $perpage";