当前位置: 首页>>代码示例>>PHP>>正文


PHP CSocNetUserRelations::GetRelationsTop方法代码示例

本文整理汇总了PHP中CSocNetUserRelations::GetRelationsTop方法的典型用法代码示例。如果您正苦于以下问题:PHP CSocNetUserRelations::GetRelationsTop方法的具体用法?PHP CSocNetUserRelations::GetRelationsTop怎么用?PHP CSocNetUserRelations::GetRelationsTop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CSocNetUserRelations的用法示例。


在下文中一共展示了CSocNetUserRelations::GetRelationsTop方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: GetRelation

	function GetRelation($firstUserID, $secondUserID)
	{
		global $DB;

		$firstUserID = IntVal($firstUserID);
		if ($firstUserID <= 0)
			return false;
		$secondUserID = IntVal($secondUserID);
		if ($secondUserID <= 0)
			return false;
			
		global $arSocNetURNCache;
		if (!isset($arSocNetURNCache) || !is_array($arSocNetURNCache) || array_key_exists("arSocNetURNCache", $_REQUEST))
			$arSocNetURNCache = array();

		if (array_key_exists($firstUserID, $arSocNetURNCache))
		{
			if (array_key_exists($secondUserID, $arSocNetURNCache[$firstUserID]))
				return $arSocNetURNCache[$firstUserID][$secondUserID];
			elseif(count($arSocNetURNCache[$firstUserID]) != 100)
				return false;
		}
		elseif (array_key_exists($secondUserID, $arSocNetURNCache))
		{
			if (array_key_exists($firstUserID, $arSocNetURNCache[$secondUserID]))
				return $arSocNetURNCache[$secondUserID][$firstUserID];
			elseif(count($arSocNetURNCache[$secondUserID]) != 100)
				return false;
		}

		// get top N relations of user1		
		$arSocNetURNCache[$firstUserID] = array();
		$dbResult = CSocNetUserRelations::GetRelationsTop($firstUserID, 100);
		while ($arResult = $dbResult->Fetch())
		{
			if ($arResult["FIRST_USER_ID"] == $firstUserID)
				$arSocNetURNCache[$firstUserID][$arResult["SECOND_USER_ID"]] = $arResult["RELATION"];
			else
				$arSocNetURNCache[$firstUserID][$arResult["FIRST_USER_ID"]] = $arResult["RELATION"];
		}

		// get top N relations of user2
		$arSocNetURNCache[$secondUserID] = array();		
		$dbResult = CSocNetUserRelations::GetRelationsTop($secondUserID, 100);
		while ($arResult = $dbResult->Fetch())
		{
			if ($arResult["FIRST_USER_ID"] == $secondUserID)
				$arSocNetURNCache[$secondUserID][$arResult["SECOND_USER_ID"]] = $arResult["RELATION"];
			else
				$arSocNetURNCache[$secondUserID][$arResult["FIRST_USER_ID"]] = $arResult["RELATION"];
		}

		global $arSocNetUserRelationsCache1;
		if (!isset($arSocNetUserRelationsCache1) || !is_array($arSocNetUserRelationsCache1) || array_key_exists("arSocNetUserRelationsCache1", $_REQUEST))
			$arSocNetUserRelationsCache1 = array();

		if (!array_key_exists($firstUserID."_".$secondUserID, $arSocNetUserRelationsCache1))
		{
			$strSql =
				"SELECT UR.RELATION ".
				"FROM b_sonet_user_relations UR ".
				"WHERE UR.FIRST_USER_ID = ".$firstUserID." ".
				"	AND UR.SECOND_USER_ID = ".$secondUserID." ".
				"UNION ".
				"SELECT UR.RELATION ".
				"FROM b_sonet_user_relations UR ".
				"WHERE UR.FIRST_USER_ID = ".$secondUserID." ".
				"	AND UR.SECOND_USER_ID = ".$firstUserID." ";

			$dbResult = $DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);
			if ($arResult = $dbResult->Fetch())
				$arSocNetUserRelationsCache1[$firstUserID."_".$secondUserID] = $arResult["RELATION"];
			else
				$arSocNetUserRelationsCache1[$firstUserID."_".$secondUserID] = false;
		}

		return $arSocNetUserRelationsCache1[$firstUserID."_".$secondUserID];
	}
开发者ID:ASDAFF,项目名称:bitrix-5,代码行数:78,代码来源:user_relations.php


注:本文中的CSocNetUserRelations::GetRelationsTop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。