當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CSearch::ReindexLock方法代碼示例

本文整理匯總了PHP中CSearch::ReindexLock方法的典型用法代碼示例。如果您正苦於以下問題:PHP CSearch::ReindexLock方法的具體用法?PHP CSearch::ReindexLock怎麽用?PHP CSearch::ReindexLock使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在CSearch的用法示例。


在下文中一共展示了CSearch::ReindexLock方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: ReIndexAll

	function ReIndexAll($bFull = false, $max_execution_time = 0, $NS = Array(), $clear_suggest = false)
	{
		global $APPLICATION;
		$DB = CDatabase::GetModuleConnection('search');

		@set_time_limit(0);
		if(!is_array($NS))
			$NS = Array();
		if($max_execution_time<=0)
		{
			$NS_OLD=$NS;
			$NS=Array("CLEAR"=>"N", "MODULE"=>"", "ID"=>"", "SESS_ID"=>md5(uniqid("")));
			if($NS_OLD["SITE_ID"]!="") $NS["SITE_ID"]=$NS_OLD["SITE_ID"];
			if($NS_OLD["MODULE_ID"]!="") $NS["MODULE_ID"]=$NS_OLD["MODULE_ID"];
		}
		$NS["CNT"] = IntVal($NS["CNT"]);
		if(!$bFull && strlen($NS["SESS_ID"])!=32)
			$NS["SESS_ID"] = md5(uniqid(""));

		$p1 = getmicrotime();

		$DB->StartTransaction();
		CSearch::ReindexLock();

		if($NS["CLEAR"] != "Y")
		{
			if($bFull)
			{
				foreach(GetModuleEvents("search", "OnBeforeFullReindexClear", true) as $arEvent)
					ExecuteModuleEventEx($arEvent);

				CSearchTags::CleanCache();
				$DB->Query("TRUNCATE TABLE b_search_content_param", false, "File: ".__FILE__."<br>Line: ".__LINE__);
				$DB->Query("TRUNCATE TABLE b_search_content_site", false, "File: ".__FILE__."<br>Line: ".__LINE__);
				$DB->Query("TRUNCATE TABLE b_search_content_right", false, "File: ".__FILE__."<br>Line: ".__LINE__);
				$DB->Query("TRUNCATE TABLE b_search_content_title", false, "File: ".__FILE__."<br>Line: ".__LINE__);
				$DB->Query("TRUNCATE TABLE b_search_tags", false, "File: ".__FILE__."<br>Line: ".__LINE__);
				$DB->Query("TRUNCATE TABLE b_search_content_freq", false, "File: ".__FILE__."<br>Line: ".__LINE__);
				$DB->Query("TRUNCATE TABLE b_search_content", false, "File: ".__FILE__."<br>Line: ".__LINE__);
				$DB->Query("TRUNCATE TABLE b_search_suggest", false, "File: ".__FILE__."<br>Line: ".__LINE__);
				$DB->Query("TRUNCATE TABLE b_search_user_right", false, "File: ".__FILE__."<br>Line: ".__LINE__);
				CSearchFullText::getInstance()->truncate();
				COption::SetOptionString("search", "full_reindex_required", "N");
			}
			elseif($clear_suggest)
			{
				$DB->Query("TRUNCATE TABLE b_search_suggest", false, "File: ".__FILE__."<br>Line: ".__LINE__);
				$DB->Query("TRUNCATE TABLE b_search_user_right", false, "File: ".__FILE__."<br>Line: ".__LINE__);
				$DB->Query("TRUNCATE TABLE b_search_content_freq", false, "File: ".__FILE__."<br>Line: ".__LINE__);
			}
		}


		$NS["CLEAR"] = "Y";

		clearstatcache();

		if(
			($NS["MODULE"]=="" || $NS["MODULE"]=="main") &&
			($NS["MODULE_ID"]=="" || $NS["MODULE_ID"]=="main")
		)
		{
			$arLangDirs = Array();
			$arFilter = Array("ACTIVE"=>"Y");
			if($NS["SITE_ID"]!="")
				$arFilter["ID"]=$NS["SITE_ID"];
			$r = CSite::GetList($by="sort", $order="asc", $arFilter);
			while($arR = $r->Fetch())
			{
				$path = rtrim($arR["DIR"], "/");
				$arLangDirs[$arR["ABS_DOC_ROOT"]."/".$path."/"] = $arR;
			}

			//get rid of duplicates
			$dub = Array();
			foreach($arLangDirs as $path=>$arR)
			{
				foreach($arLangDirs as $path2=>$arR2)
				{
					if($path==$path2) continue;
					if(substr($path, 0, strlen($path2)) == $path2)
						$dub[] = $path;
				}
			}

			foreach($dub as $p)
				unset($arLangDirs[$p]);

			foreach($arLangDirs as $arR)
			{
				$site = $arR["ID"];
				$path = rtrim($arR["DIR"], "/");
				$site_path = $site."|".$path."/";

				if(
					$max_execution_time > 0
					&& $NS["MODULE"] == "main"
					&& substr($NS["ID"]."/", 0, strlen($site_path)) != $site_path
				)
					continue;
//.........這裏部分代碼省略.........
開發者ID:nycmic,項目名稱:bittest,代碼行數:101,代碼來源:search.php


注:本文中的CSearch::ReindexLock方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。