本文整理汇总了PHP中Relationship::my_friends方法的典型用法代码示例。如果您正苦于以下问题:PHP Relationship::my_friends方法的具体用法?PHP Relationship::my_friends怎么用?PHP Relationship::my_friends使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Relationship
的用法示例。
在下文中一共展示了Relationship::my_friends方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: user_friends
public function user_friends($uid, $startresults = 0, $totalresults = 20, $orderby = "friend", $orderdirection = "DESC", $ignoreusers = 0)
{
$db = new Database();
$db->connect();
$sess = new SessionData('account');
$id = $sess->Retrieve('id');
if ($id == $uid) {
// run my_friends now to return more results than just user ids
$myfriends = Relationship::my_friends($startresults, $totalresults, $orderby, $orderdirection, $ignoreusers);
return $myfriends;
}
$relationshipquery = "\n\t\t\t\t\t(select distinct SQL_CALC_FOUND_ROWS\n\t\t\t\t\tr.senderid as friend\n\t\t\t\t\tfrom relationship r\n\t\t\t\t\tjoin user u on u.id=r.senderid\n\t\t\t\t\tWHERE r.receiverid IN (" . $uid . ")\n\t\t\t\t\tand r.senderid NOT IN (" . $ignoreusers . ")\n\t\t\t\t\tand r.senderid != '" . $id . "'\n\t\t\t\t\tand r.confirmed=1\n\t\t\t\t\tand u.accountstatusid>1)\n\t\t\t\t\tUNION\n\t\t\t\t\t(select distinct \n\t\t\t\t\tr.receiverid as friend\n\t\t\t\t\tfrom relationship r\n\t\t\t\t\tjoin user u on u.id=r.receiverid\n\t\t\t\t\tWHERE r.senderid IN (" . $uid . ")\n\t\t\t\t\tand r.receiverid NOT IN (" . $ignoreusers . ")\n\t\t\t\t\tand r.receiverid != '" . $id . "'\n\t\t\t\t\tand r.confirmed=1\n\t\t\t\t\tand u.accountstatusid>1)\n\t\t\t\t\torder by " . $orderby . " " . $orderdirection . "\n\t\t\t\t\tlimit " . $startresults . ", " . $totalresults . "\n\t\t\t\t\t";
$db->query($relationshipquery);
$tmp = $db->getresult();
if ($tmp[0]['friend'] < 1) {
$tmp2[0]['friend'] = $tmp['friend'];
} else {
$tmp2 = $tmp;
}
$farray = array();
foreach ($tmp2 as $spaceid => $frienddata) {
$farray[$spaceid] = $frienddata['friend'];
}
Profile::set_totalrows($db->getTotalRows());
//if($farray[0]<1) $farray[0]=$id;
return $farray;
}
示例2: viewable_profile
public function viewable_profile($uid)
{
if ($uid == 4) {
return "Master and Commander";
}
$sess = new SessionData('account');
$id = $sess->Retrieve('id');
if ($id == $uid) {
return "This is you.";
}
$relation = new Relationship();
$their_friends = $relation->user_friends($uid, 0, 5000);
$my_friends = $relation->my_friends();
$connections = count(array_intersect($my_friends, $their_friends));
$retvalue = $relation->find_connection($uid);
if ($retvalue) {
$retvalue .= "<br>You have <a href='search.php?mfriends={$uid}&hide=y'>" . $connections . " friend";
if ($connections != 1) {
$retvalue .= "s";
}
$retvalue .= "</a> in common.";
return $retvalue;
}
if ($connections > 0) {
$retvalue = "This is a friend of a friend.<br>You have <a href='search.php?mfriends={$uid}&hide=y'>" . $connections . " friend";
if ($connections != 1) {
$retvalue .= "s";
}
$retvalue .= "</a> in common.";
return $retvalue;
}
$pendingrequest = $relation->pending_requests();
if (in_array($uid, $pendingrequest)) {
$retvalue = "Pending Request.<br>You have <a href='search.php?mfriends={$uid}&hide=y'>" . $connections . " friend";
if ($connections != 1) {
$retvalue .= "s";
}
$retvalue .= "</a> in common.";
return $retvalue;
}
return FALSE;
}