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


PHP CUserCounter::counters方法代码示例

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


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

示例1: IncrementWithSelect

	public static function IncrementWithSelect($sub_select, $sendPull = true)
	{
		global $DB, $CACHE_MANAGER, $APPLICATION;

		if (strlen($sub_select) > 0)
		{
			$pullInclude = $sendPull && self::CheckLiveMode();
			$strSQL = "
				INSERT INTO b_user_counter (USER_ID, CNT, SITE_ID, CODE, SENT) (".$sub_select.")
				ON DUPLICATE KEY UPDATE CNT = CNT + VALUES(CNT), SENT = VALUES(SENT)
			";
			$DB->Query($strSQL, false, "FILE: ".__FILE__."<br> LINE: ".__LINE__);

			self::$counters = false;
			$CACHE_MANAGER->CleanDir("user_counter");

			if ($pullInclude)
			{
				$db_lock = $DB->Query("SELECT GET_LOCK('".$APPLICATION->GetServerUniqID()."_pull', 0) as L");
				$ar_lock = $db_lock->Fetch();
				if($ar_lock["L"] > 0)
				{
					$arSites = Array();
					$res = CSite::GetList(($b = ""), ($o = ""), Array("ACTIVE" => "Y"));
					while($row = $res->Fetch())
						$arSites[] = $row['ID'];

					$strSQL = "
						SELECT distinct pc.CHANNEL_ID, uc1.USER_ID, uc1.SITE_ID, uc1.CODE, uc1.CNT
						FROM b_user_counter uc
						INNER JOIN b_user_counter uc1 ON uc1.USER_ID = uc.USER_ID AND uc1.CODE = uc.CODE
						INNER JOIN b_pull_channel pc ON pc.USER_ID = uc.USER_ID
						WHERE uc.SENT = '0'
					";
					$res = $DB->Query($strSQL, false, "FILE: ".__FILE__."<br> LINE: ".__LINE__);

					$pullMessage = Array();
					while($row = $res->Fetch())
					{
						if ($row['SITE_ID'] == '**')
						{
							foreach($arSites as $siteId)
							{
								if (isset($pullMessage[$row['CHANNEL_ID']][$siteId][$row['CODE']]))
									$pullMessage[$row['CHANNEL_ID']][$siteId][$row['CODE']] += intval($row['CNT']);
								else
									$pullMessage[$row['CHANNEL_ID']][$siteId][$row['CODE']] = intval($row['CNT']);
							}
						}
						else
						{
							if (isset($pullMessage[$row['CHANNEL_ID']][$row['SITE_ID']][$row['CODE']]))
								$pullMessage[$row['CHANNEL_ID']][$row['SITE_ID']][$row['CODE']] += intval($row['CNT']);
							else
								$pullMessage[$row['CHANNEL_ID']][$row['SITE_ID']][$row['CODE']] = intval($row['CNT']);
						}
					}

					$DB->Query("UPDATE b_user_counter SET SENT = '1' WHERE SENT = '0'");
					$DB->Query("SELECT RELEASE_LOCK('".$APPLICATION->GetServerUniqID()."_pull')");

					foreach ($pullMessage as $channelId => $arMessage)
					{
						CPullStack::AddByChannel($channelId, Array(
							'module_id' => 'main',
							'command' => 'user_counter',
							'params' => $arMessage,
						));
					}
				}
			}
		}
	}
开发者ID:ASDAFF,项目名称:bxApiDocs,代码行数:73,代码来源:user_counter.php

示例2: DeleteByCode

 public static function DeleteByCode($code)
 {
     global $DB, $APPLICATION, $CACHE_MANAGER;
     if (strlen($code) <= 0) {
         return false;
     }
     $pullMessage = array();
     $bPullEnabled = false;
     if (self::CheckLiveMode()) {
         $db_lock = $DB->Query("SELECT GET_LOCK('" . $APPLICATION->GetServerUniqID() . "_pull', 0) as L");
         $ar_lock = $db_lock->Fetch();
         if ($ar_lock["L"] > 0) {
             $bPullEnabled = true;
             $arSites = array();
             $res = CSite::GetList($b = "", $o = "", array("ACTIVE" => "Y"));
             while ($row = $res->Fetch()) {
                 $arSites[] = $row['ID'];
             }
             $strSQL = "\n\t\t\t\t\tSELECT distinct pc.CHANNEL_ID, uc.USER_ID, uc.SITE_ID, uc.CODE, uc.CNT\n\t\t\t\t\tFROM b_user_counter uc\n\t\t\t\t\tINNER JOIN b_pull_channel pc ON pc.USER_ID = uc.USER_ID\n\t\t\t\t\tWHERE uc.CODE LIKE '**%'\n\t\t\t\t";
             $res = $DB->Query($strSQL, false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__);
             while ($row = $res->Fetch()) {
                 if ($row["CODE"] == $code) {
                     continue;
                 }
                 CUserCounter::addValueToPullMessage($row, $arSites, $pullMessage);
             }
         }
     }
     $DB->Query("DELETE FROM b_user_counter WHERE CODE = '" . $code . "'", false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__);
     self::$counters = false;
     $CACHE_MANAGER->CleanDir("user_counter");
     if ($bPullEnabled) {
         $DB->Query("SELECT RELEASE_LOCK('" . $APPLICATION->GetServerUniqID() . "_pull')");
     }
     foreach ($pullMessage as $channelId => $arMessage) {
         CPullStack::AddByChannel($channelId, array('module_id' => 'main', 'command' => 'user_counter', 'params' => $arMessage));
     }
 }
开发者ID:Satariall,项目名称:izurit,代码行数:38,代码来源:user_counter.php

示例3: IncrementWithSelect

 public static function IncrementWithSelect($sub_select)
 {
     global $DB, $CACHE_MANAGER;
     if (strlen($sub_select) > 0) {
         $strSQL = "\n\t\t\t\tINSERT INTO b_user_counter (USER_ID, CNT, SITE_ID, CODE) (" . $sub_select . ")\n\t\t\t\tON DUPLICATE KEY UPDATE CNT = CNT + 1\n\t\t\t";
         $DB->Query($strSQL, false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__);
         self::$counters = false;
         $CACHE_MANAGER->CleanDir("user_counter");
     }
 }
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:10,代码来源:user_counter.php

示例4: IncrementWithSelect

 public static function IncrementWithSelect($sub_select, $sendPull = true, $arParams = array())
 {
     global $DB, $CACHE_MANAGER, $APPLICATION;
     if (strlen($sub_select) > 0) {
         $pullInclude = $sendPull && self::CheckLiveMode();
         if (is_array($arParams) && isset($arParams["TAG_SET"])) {
             $strSQL = "\n\t\t\t\t\tINSERT INTO b_user_counter (USER_ID, CNT, SITE_ID, CODE, SENT, TAG) (" . $sub_select . ")\n\t\t\t\t\tON DUPLICATE KEY UPDATE CNT = CNT + VALUES(CNT), SENT = VALUES(SENT), TAG = '" . $DB->ForSQL($arParams["TAG_SET"]) . "'\n\t\t\t\t";
         } elseif (is_array($arParams) && isset($arParams["TAG_CHECK"])) {
             $strSQL = "\n\t\t\t\t\tINSERT INTO b_user_counter (USER_ID, CNT, SITE_ID, CODE, SENT) (" . $sub_select . ")\n\t\t\t\t\tON DUPLICATE KEY UPDATE CNT = CASE\n\t\t\t\t\t\tWHEN\n\t\t\t\t\t\t\tTAG = '" . $DB->ForSQL($arParams["TAG_CHECK"]) . "'\n\t\t\t\t\t\tTHEN\n\t\t\t\t\t\t\tCNT\n\n\t\t\t\t\t\tELSE\n\t\t\t\t\t\t\tCNT + VALUES(CNT)\n\t\t\t\t\t\tEND,\n\t\t\t\t\t\tSENT = CASE\n\t\t\t\t\t\tWHEN\n\t\t\t\t\t\t\tTAG = '" . $DB->ForSQL($arParams["TAG_CHECK"]) . "'\n\t\t\t\t\t\tTHEN\n\t\t\t\t\t\t\tSENT\n\t\t\t\t\t\tELSE\n\t\t\t\t\t\t\tSENT = VALUES(SENT)\n\t\t\t\t\t\tEND\n\t\t\t\t";
         } else {
             $strSQL = "\n\t\t\t\t\tINSERT INTO b_user_counter (USER_ID, CNT, SITE_ID, CODE, SENT) (" . $sub_select . ")\n\t\t\t\t\tON DUPLICATE KEY UPDATE CNT = CNT + VALUES(CNT), SENT = VALUES(SENT)\n\t\t\t\t";
         }
         $DB->Query($strSQL, false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__);
         if (!is_array($arParams) || !isset($arParams["TAG_SET"])) {
             self::$counters = false;
             $CACHE_MANAGER->CleanDir("user_counter");
         }
         if ($pullInclude) {
             $db_lock = $DB->Query("SELECT GET_LOCK('" . $APPLICATION->GetServerUniqID() . "_pull', 0) as L");
             $ar_lock = $db_lock->Fetch();
             if ($ar_lock["L"] > 0) {
                 $arSites = array();
                 $res = CSite::GetList($b = "", $o = "", array("ACTIVE" => "Y"));
                 while ($row = $res->Fetch()) {
                     $arSites[] = $row['ID'];
                 }
                 $strSQL = "\n\t\t\t\t\t\tSELECT distinct pc.CHANNEL_ID, uc1.USER_ID, uc1.SITE_ID, uc1.CODE, uc1.CNT\n\t\t\t\t\t\tFROM b_user_counter uc\n\t\t\t\t\t\tINNER JOIN b_user_counter uc1 ON uc1.USER_ID = uc.USER_ID AND uc1.CODE = uc.CODE\n\t\t\t\t\t\tINNER JOIN b_pull_channel pc ON pc.USER_ID = uc.USER_ID\n\t\t\t\t\t\tWHERE uc.SENT = '0'\n\t\t\t\t\t";
                 $res = $DB->Query($strSQL, false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__);
                 $pullMessage = array();
                 while ($row = $res->Fetch()) {
                     if ($row['SITE_ID'] == self::ALL_SITES) {
                         foreach ($arSites as $siteId) {
                             if (isset($pullMessage[$row['CHANNEL_ID']][$siteId][$row['CODE']])) {
                                 $pullMessage[$row['CHANNEL_ID']][$siteId][$row['CODE']] += intval($row['CNT']);
                             } else {
                                 $pullMessage[$row['CHANNEL_ID']][$siteId][$row['CODE']] = intval($row['CNT']);
                             }
                         }
                     } else {
                         if (isset($pullMessage[$row['CHANNEL_ID']][$row['SITE_ID']][$row['CODE']])) {
                             $pullMessage[$row['CHANNEL_ID']][$row['SITE_ID']][$row['CODE']] += intval($row['CNT']);
                         } else {
                             $pullMessage[$row['CHANNEL_ID']][$row['SITE_ID']][$row['CODE']] = intval($row['CNT']);
                         }
                     }
                 }
                 $DB->Query("UPDATE b_user_counter SET SENT = '1' WHERE SENT = '0'");
                 $DB->Query("SELECT RELEASE_LOCK('" . $APPLICATION->GetServerUniqID() . "_pull')");
                 foreach ($pullMessage as $channelId => $arMessage) {
                     CPullStack::AddByChannel($channelId, array('module_id' => 'main', 'command' => 'user_counter', 'params' => $arMessage));
                 }
             }
         }
     }
 }
开发者ID:rasuldev,项目名称:torino,代码行数:55,代码来源:user_counter.php


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