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


PHP CBlog::PrepareSql方法代码示例

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


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

示例1: GetList

 public static function GetList($arOrder = array("ID" => "DESC"), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array())
 {
     if (!CModule::IncludeModule('blog')) {
         return false;
     }
     global $DB;
     if (count($arSelectFields) == 0) {
         $arSelectFields = array("ID", "USER_ID", "USER_EMAIL");
     }
     // FIELDS -->
     $arFields = array("ID" => array("FIELD" => "IES.ID", "TYPE" => "string"), "USER_ID" => array("FIELD" => "IES.USER_ID", "TYPE" => "int"), "USER_EMAIL" => array("FIELD" => "U.EMAIL", "TYPE" => "string", "FROM" => "INNER JOIN b_user U ON (IES.USER_ID = U.ID)"));
     $arSqls = CBlog::PrepareSql($arFields, $arOrder, $arFilter, $arGroupBy, $arSelectFields);
     $arSqls["SELECT"] = str_replace("%%_DISTINCT_%%", "", $arSqls["SELECT"]);
     //Make Query
     $strSql = "SELECT " . $arSqls["SELECT"] . " " . "FROM b_idea_email_subscribe IES " . " " . $arSqls["FROM"] . " ";
     if (strlen($arSqls["WHERE"]) > 0) {
         $strSql .= "WHERE " . $arSqls["WHERE"] . " ";
     }
     if (strlen($arSqls["GROUPBY"]) > 0) {
         $strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
     }
     if (strlen($arSqls["ORDERBY"]) > 0) {
         $strSql .= "ORDER BY " . $arSqls["ORDERBY"] . " ";
     }
     return $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
 }
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:26,代码来源:idea_email_notify.php

示例2: GetList

 public static function GetList($arOrder = array("ID" => "ASC"), $arFilter = array(), $arAddParams = array())
 {
     global $DB;
     $arFields = array("ID" => array("FIELD" => "BPP.ID", "TYPE" => "int"), "POST_ID" => array("FIELD" => "BPP.POST_ID", "TYPE" => "int"), "USER_ID" => array("FIELD" => "BPP.USER_ID", "TYPE" => "int"), "NAME" => array("FIELD" => "BPP.NAME", "TYPE" => "string"), "VALUE" => array("FIELD" => "BPP.VALUE", "TYPE" => "string"), "RANK" => $arOrder["OWNER_ID"] > 0 ? array("FIELD" => "RV0.RANK", "TYPE" => "int", "FROM" => "\n\tLEFT JOIN (\n\t\t" . "SELECT MAX(RV2.VOTE_WEIGHT) as VOTE_WEIGHT, RV2.ENTITY_ID \n\t\t" . "FROM b_rating_user RV2 \n\t\t" . "GROUP BY RV2.ENTITY_ID) RV ON (RV.ENTITY_ID = BPP.USER_ID)\n\t" . "LEFT JOIN (\n\t\t" . "SELECT RV1.OWNER_ID, SUM(case when RV1.ID is not null then 1 else 0 end) as RANK \n\t\t" . "FROM b_rating_vote RV1 \n\t\t" . "WHERE RV1.USER_ID = " . $arOrder["OWNER_ID"] . "\n\t\t" . "GROUP BY RV1.OWNER_ID) RV0 ON (RV0.OWNER_ID = BPP.USER_ID)") : array("FIELD" => "RV.RANK", "TYPE" => "string", "FROM" => "\n\tLEFT JOIN (" . "\n\t\tSELECT MAX(RV2.VOTE_WEIGHT) as VOTE_WEIGHT, RV2.ENTITY_ID, 0 as RANK " . "\n\t\tFROM b_rating_user RV2" . "\n\t\tGROUP BY RV2.ENTITY_ID) RV ON (RV.ENTITY_ID = BPP.USER_ID)"), "USER_ACTIVE" => array("FIELD" => "U.ACTIVE", "TYPE" => "string", "FROM" => "\n\tINNER JOIN b_user U ON (BPP.USER_ID = U.ID)"), "USER_NAME" => array("FIELD" => "U.NAME", "TYPE" => "string", "FROM" => "\n\tINNER JOIN b_user U ON (BPP.USER_ID = U.ID)"), "USER_LAST_NAME" => array("FIELD" => "U.LAST_NAME", "TYPE" => "string", "FROM" => "\n\tINNER JOIN b_user U ON (BPP.USER_ID = U.ID)"), "USER_SECOND_NAME" => array("FIELD" => "U.SECOND_NAME", "TYPE" => "string", "FROM" => "\n\tINNER JOIN b_user U ON (BPP.USER_ID = U.ID)"), "USER_LOGIN" => array("FIELD" => "U.LOGIN", "TYPE" => "string", "FROM" => "\n\tINNER JOIN b_user U ON (BPP.USER_ID = U.ID)"), "USER_PERSONAL_PHOTO" => array("FIELD" => "U.PERSONAL_PHOTO", "TYPE" => "string", "FROM" => "\n\tINNER JOIN b_user U ON (BPP.USER_ID = U.ID)"));
     $arSelect = array_diff(array_keys($arFields), array("RANK"));
     $arSelect = is_array($arAddParams["SELECT"]) && !empty($arAddParams["SELECT"]) ? array_intersect($arAddParams["SELECT"], $arSelect) : $arSelect;
     $arSql = CBlog::PrepareSql($arFields, array(), $arFilter, false, $arSelect);
     $arSql["SELECT"] = str_replace("%%_DISTINCT_%%", "", $arSql["SELECT"]);
     $iCnt = 0;
     if ($arAddParams["bCount"] || array_key_exists("bDescPageNumbering", $arAddParams)) {
         $strSql = "SELECT COUNT(BPP.ID) AS CNT  \n" . "FROM b_blog_post_param BPP " . $arSql["FROM"] . "\n" . (empty($arSql["GROUPBY"]) ? "" : "GROUP BY " . $arSql["GROUPBY"] . "\n") . "WHERE " . (empty($arSql["WHERE"]) ? "1 = 1" : $arSql["WHERE"]);
         $db_res = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         if ($arAddParams["bCount"]) {
             return $db_res;
         }
         $iCnt = $db_res && ($res = $db_res->Fetch()) ? intval($res["CNT"]) : 0;
     }
     // ORDER BY -->
     $arSqlOrder = array();
     foreach ($arOrder as $by => $order) {
         $by = strtoupper($by);
         $order = strtoupper($order) != "ASC" ? "DESC" : "ASK";
         if (array_key_exists($by, $arFields) && !array_key_exists($by, $arSqlOrder)) {
             if (strtoupper($DB->type) == "ORACLE") {
                 $order .= $order == "ASC" ? " NULLS FIRST" : " NULLS LAST";
             }
             if (isset($arFields[$by]["FROM"]) && !empty($arFields[$by]["FROM"]) && strpos($arSql["FROM"], $arFields[$by]["FROM"]) === false) {
                 $arSql["FROM"] .= " " . $arFields[$by]["FROM"];
             }
             if ($by == "RANK") {
                 $arSql["SELECT"] .= ", " . $arFields["RANK"]["FIELD"];
                 $arSqlOrder[$by] = IsModuleInstalled("intranet") ? "RV.VOTE_WEIGHT " . $order . ", RANK " . $order : "RANK " . $order . ", RV.VOTE_WEIGHT " . $order;
             } else {
                 $arSqlOrder[$by] = (array_key_exists("ORDER", $arFields[$by]) ? $arFields[$by]["ORDER"] : $arFields[$by]["FIELD"]) . " " . $order;
             }
         }
     }
     DelDuplicateSort($arSqlOrder);
     $arSql["ORDERBY"] = implode(", ", $arSqlOrder);
     // <-- ORDER BY
     $strSql = "SELECT " . $arSql["SELECT"] . "\n" . "FROM b_blog_post_param BPP" . $arSql["FROM"] . "\n" . "WHERE " . (empty($arSql["WHERE"]) ? "1 = 1" : $arSql["WHERE"]) . (empty($arSql["ORDERBY"]) ? "" : "\nORDER BY " . $arSql["ORDERBY"]);
     if (is_set($arAddParams, "bDescPageNumbering")) {
         $db_res = new CDBResult();
         $db_res->NavQuery($strSql, $iCnt, $arAddParams);
     } else {
         $db_res = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     }
     return $db_res;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:49,代码来源:blog_post_param.php

示例3: GetList

	function GetList($arOrder = Array("ID" => "DESC"), $arFilter = Array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array())
	{
		global $DB;

		if (count($arSelectFields) <= 0)
			$arSelectFields = array("ID", "BLOG_ID", "NAME");

		// FIELDS -->
		$arFields = array(
			"ID" => array("FIELD" => "G.ID", "TYPE" => "int"),
			"BLOG_ID" => array("FIELD" => "G.BLOG_ID", "TYPE" => "int"),
			"NAME" => array("FIELD" => "G.NAME", "TYPE" => "string"),
			"USER2GROUP_ID" => array("FIELD" => "U2UG.ID", "TYPE" => "int", "FROM" => "INNER JOIN b_blog_user2user_group U2UG ON (G.ID = U2UG.USER_GROUP_ID AND G.BLOG_ID = U2UG.BLOG_ID)"),
			"USER2GROUP_USER_ID" => array("FIELD" => "U2UG.USER_ID", "TYPE" => "int", "FROM" => "INNER JOIN b_blog_user2user_group U2UG ON (G.ID = U2UG.USER_GROUP_ID AND G.BLOG_ID = U2UG.BLOG_ID)"),
		);
		// <-- FIELDS

		$arSqls = CBlog::PrepareSql($arFields, $arOrder, $arFilter, $arGroupBy, $arSelectFields);

		$arSqls["SELECT"] = str_replace("%%_DISTINCT_%%", "", $arSqls["SELECT"]);

		if (is_array($arGroupBy) && count($arGroupBy)==0)
		{
			$strSql =
				"SELECT ".$arSqls["SELECT"]." ".
				"FROM b_blog_user_group G ".
				"	".$arSqls["FROM"]." ";
			if (strlen($arSqls["WHERE"]) > 0)
				$strSql .= "WHERE ".$arSqls["WHERE"]." ";
			if (strlen($arSqls["GROUPBY"]) > 0)
				$strSql .= "GROUP BY ".$arSqls["GROUPBY"]." ";

			//echo "!1!=".htmlspecialcharsbx($strSql)."<br>";

			$dbRes = $DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);
			if ($arRes = $dbRes->Fetch())
				return $arRes["CNT"];
			else
				return False;
		}

		$strSql =
			"SELECT ".$arSqls["SELECT"]." ".
			"FROM b_blog_user_group G ".
			"	".$arSqls["FROM"]." ";
		if (strlen($arSqls["WHERE"]) > 0)
			$strSql .= "WHERE ".$arSqls["WHERE"]." ";
		if (strlen($arSqls["GROUPBY"]) > 0)
			$strSql .= "GROUP BY ".$arSqls["GROUPBY"]." ";
		if (strlen($arSqls["ORDERBY"]) > 0)
			$strSql .= "ORDER BY ".$arSqls["ORDERBY"]." ";

		if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"])<=0)
		{
			$strSql_tmp =
				"SELECT COUNT('x') as CNT ".
				"FROM b_blog_user_group G ".
				"	".$arSqls["FROM"]." ";
			if (strlen($arSqls["WHERE"]) > 0)
				$strSql_tmp .= "WHERE ".$arSqls["WHERE"]." ";
			if (strlen($arSqls["GROUPBY"]) > 0)
				$strSql_tmp .= "GROUP BY ".$arSqls["GROUPBY"]." ";

			//echo "!2.1!=".htmlspecialcharsbx($strSql_tmp)."<br>";

			$dbRes = $DB->Query($strSql_tmp, false, "File: ".__FILE__."<br>Line: ".__LINE__);
			$cnt = 0;
			if (strlen($arSqls["GROUPBY"]) <= 0)
			{
				if ($arRes = $dbRes->Fetch())
					$cnt = $arRes["CNT"];
			}
			else
			{
				// ТОЛЬКО ДЛЯ MYSQL!!! ДЛЯ ORACLE ДРУГОЙ КОД
				$cnt = $dbRes->SelectedRowsCount();
			}

			$dbRes = new CDBResult();

			//echo "!2.2!=".htmlspecialcharsbx($strSql)."<br>";

			$dbRes->NavQuery($strSql, $cnt, $arNavStartParams);
		}
		else
		{
			if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) > 0)
				$strSql .= "LIMIT ".IntVal($arNavStartParams["nTopCount"]);

			//echo "!3!=".htmlspecialcharsbx($strSql)."<br>";

			$dbRes = $DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);
		}

		return $dbRes;
	}
开发者ID:ASDAFF,项目名称:entask.ru,代码行数:96,代码来源:blog_user_group.php

示例4: GetList


//.........这里部分代码省略.........
			{
				$arSelectFields[] = 'RATING_USER_VOTE_VALUE';
				$arFields["RATING_USER_VOTE_VALUE"] =  Array("FIELD" => $DB->IsNull('RVV.VALUE', '0'), "ORDER" => "RATING_USER_VOTE_VALUE",  "TYPE" => "double", "FROM" => "LEFT JOIN b_rating_vote RVV ON RVV.ENTITY_TYPE_ID = 'BLOG_POST' AND RVV.ENTITY_ID = P.ID  AND RVV.USER_ID = ".intval($USER->GetId()));
			}
		}

		// <-- FIELDS
		$bNeedDistinct = false;
		$blogModulePermissions = $GLOBALS["APPLICATION"]->GetGroupRight("blog");
		if ($blogModulePermissions < "W")
		{
			$user_id = 0;
			if(isset($USER) && is_object($USER) && $USER->IsAuthorized())
				$user_id = $GLOBALS["USER"]->GetID();

			if(!CBlog::IsBlogOwner($arFilter["BLOG_ID"], $user_id))
			{
				$arUserGroups = CBlogUser::GetUserGroups($user_id, IntVal($arFilter["BLOG_ID"]), "Y", BLOG_BY_USER_ID);
				$strUserGroups = "0";
				foreach($arUserGroups as $v)
					$strUserGroups .= ",".IntVal($v);

				$arFields["PERMS"] = array("FIELD" => "UGP.PERMS", "TYPE" => "string", "FROM" => "INNER JOIN b_blog_user_group_perms UGP ON (P.ID = UGP.POST_ID AND P.BLOG_ID = UGP.BLOG_ID AND UGP.USER_GROUP_ID IN (".$strUserGroups.") AND UGP.PERMS_TYPE = '".BLOG_PERMS_POST."')");
				$bNeedDistinct = true;
			}
			else
				$arFields["PERMS"] = array("FIELD" => "'W'", "TYPE" => "string");
		}
		else
		{
			$arFields["PERMS"] = array("FIELD" => "'W'", "TYPE" => "string");
		}

		$arSqls = CBlog::PrepareSql($arFields, $arOrder, $arFilter, $arGroupBy, $arSelectFields, $obUserFieldsSql);

		if(array_key_exists("SOCNET_GROUP_ID", $arFilter) || array_key_exists("SOCNET_GROUP_ID", $arFilter))
			$bNeedDistinct = true;
		if(array_key_exists("FOR_USER", $arFilter))
		{
			if(IntVal($arFilter["FOR_USER"]) > 0) //authorized user
			{
				if($arFilter["FOR_USER_TYPE"] == "ALL")
				{
					$arSqls["FROM"] .=
								" INNER JOIN b_blog_socnet_rights SR ON (P.ID = SR.POST_ID) ".
								" LEFT JOIN b_user_access UA ON (UA.ACCESS_CODE = SR.ENTITY AND UA.USER_ID = ".IntVal($arFilter["FOR_USER"]).") ";
					if(strlen($arSqls["WHERE"]) > 0)
						$arSqls["WHERE"] .= " AND ";
					$arSqls["WHERE"] .= " (SR.ENTITY_TYPE != 'SG') AND ".
										" (SR.ENTITY = 'U".IntVal($arFilter["FOR_USER"])."' OR (UA.USER_ID is not NULL AND SR.ENTITY_TYPE = 'DR') OR P.AUTHOR_ID = '".IntVal($arFilter["FOR_USER"])."')";
				}
				elseif($arFilter["FOR_USER_TYPE"] == "SELF")
				{
					$arSqls["FROM"] .=
								" INNER JOIN b_blog_socnet_rights SR ON (P.ID = SR.POST_ID) ".
								" LEFT JOIN b_user_access UA ON (UA.ACCESS_CODE = SR.ENTITY AND UA.USER_ID = ".IntVal($arFilter["FOR_USER"]).") ";
					if(strlen($arSqls["WHERE"]) > 0)
						$arSqls["WHERE"] .= " AND ";
					$arSqls["WHERE"] .= " (SR.ENTITY = 'U".IntVal($arFilter["FOR_USER"])."' OR (UA.USER_ID is not NULL AND SR.ENTITY_TYPE = 'DR')) ";
				}
				elseif($arFilter["FOR_USER_TYPE"] == "DR")
				{
					$arSqls["FROM"] .=
								" INNER JOIN b_blog_socnet_rights SR ON (P.ID = SR.POST_ID) " .
								" LEFT JOIN b_user_access UA ON (UA.ACCESS_CODE = SR.ENTITY AND UA.USER_ID = ".IntVal($arFilter["FOR_USER"]).") ";
					if(strlen($arSqls["WHERE"]) > 0)
开发者ID:akniyev,项目名称:arteva.ru,代码行数:67,代码来源:blog_post.php

示例5: GetList


//.........这里部分代码省略.........
		
		// rating variable	
		if ( 
			in_array("RATING_TOTAL_VOTES", $arSelectFields) || 
			in_array("RATING_TOTAL_POSITIVE_VOTES", $arSelectFields) || 
			in_array("RATING_TOTAL_NEGATIVE_VOTES", $arSelectFields) || 
			array_key_exists("RATING_TOTAL_VALUE", $arOrder) || 
			array_key_exists("RATING_TOTAL_VOTES", $arOrder)
		)
		{
			$arFields["RATING_TOTAL_VALUE"] = array("FIELD" => $DB->IsNull('RV.TOTAL_VALUE', '0'), "TYPE" => "double", "FROM" => "LEFT JOIN b_rating_voting RV ON ( RV.ENTITY_TYPE_ID = 'BLOG_COMMENT' AND RV.ENTITY_ID = C.ID )");
			$arFields["RATING_TOTAL_VOTES"] = array("FIELD" => $DB->IsNull('RV.TOTAL_VOTES', '0'), "TYPE" => "int", "FROM" => "LEFT JOIN b_rating_voting RV ON ( RV.ENTITY_TYPE_ID = 'BLOG_COMMENT' AND RV.ENTITY_ID = C.ID )");
			$arFields["RATING_TOTAL_POSITIVE_VOTES"] = array("FIELD" => $DB->IsNull('RV.TOTAL_POSITIVE_VOTES', '0'), "TYPE" => "int", "FROM" => "LEFT JOIN b_rating_voting RV ON ( RV.ENTITY_TYPE_ID = 'BLOG_COMMENT' AND RV.ENTITY_ID = C.ID )");
			$arFields["RATING_TOTAL_NEGATIVE_VOTES"] = array("FIELD" => $DB->IsNull('RV.TOTAL_NEGATIVE_VOTES', '0'), "TYPE" => "int", "FROM" => "LEFT JOIN b_rating_voting RV ON ( RV.ENTITY_TYPE_ID = 'BLOG_COMMENT' AND RV.ENTITY_ID = C.ID )");
		}

		$bNeedDistinct = false;
		$blogModulePermissions = $GLOBALS["APPLICATION"]->GetGroupRight("blog");
		if ($blogModulePermissions < "W")
		{	
			$arUserGroups = CBlogUser::GetUserGroups(($GLOBALS["USER"]->IsAuthorized() ? $GLOBALS["USER"]->GetID() : 0), 0, "Y", BLOG_BY_USER_ID);
			$strUserGroups = "0";
			foreach($arUserGroups as $v)
				$strUserGroups .= ",".IntVal($v);

			$arFields["PERMS"] = array("FIELD" => "UGP.PERMS", "TYPE" => "char", "FROM" => "INNER JOIN b_blog_user_group_perms UGP ON (C.POST_ID = UGP.POST_ID AND C.BLOG_ID = UGP.BLOG_ID AND UGP.USER_GROUP_ID IN (".$strUserGroups.") AND UGP.PERMS_TYPE = '".BLOG_PERMS_COMMENT."')");
			$bNeedDistinct = true;
		}		
		else
		{
			$arFields["PERMS"] = array("FIELD" => "'W'", "TYPE" => "string");
		}

		$arSqls = CBlog::PrepareSql($arFields, $arOrder, $arFilter, $arGroupBy, $arSelectFields, $obUserFieldsSql);
		if(array_key_exists("FOR_USER", $arFilter))
		{
			if(IntVal($arFilter["FOR_USER"]) > 0) //authorized user
			{
					$arSqls["FROM"] .=
								" INNER JOIN b_blog_socnet_rights SR ON (C.POST_ID = SR.POST_ID) " .
								" LEFT JOIN b_user_access UA ON (UA.ACCESS_CODE = SR.ENTITY AND UA.USER_ID = ".IntVal($arFilter["FOR_USER"]).") ";
					if(strlen($arSqls["WHERE"]) > 0)
						$arSqls["WHERE"] .= " AND ";
					$arSqls["WHERE"] .= " (UA.USER_ID is not NULL OR SR.ENTITY = 'AU') ";
			}
			else
			{
				$arSqls["FROM"] .=
							" INNER JOIN b_blog_socnet_rights SR ON (C.POST_ID = SR.POST_ID) ".
							" INNER JOIN b_user_access UA ON (UA.ACCESS_CODE = SR.ENTITY AND UA.USER_ID = 0)";
			}
			$bNeedDistinct = true;
		}

		if($bNeedDistinct)
			$arSqls["SELECT"] = str_replace("%%_DISTINCT_%%", "DISTINCT", $arSqls["SELECT"]);
		else
			$arSqls["SELECT"] = str_replace("%%_DISTINCT_%%", "", $arSqls["SELECT"]);
		
		$r = $obUserFieldsSql->GetFilter();
		if(strlen($r)>0)
			$strSqlUFFilter = " (".$r.") ";

		if (is_array($arGroupBy) && count($arGroupBy)==0)
		{
			$strSql =
开发者ID:ASDAFF,项目名称:bxApiDocs,代码行数:67,代码来源:blog_comment.php

示例6: GetList

 public static function GetList($arOrder = array("ID" => "DESC"), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array())
 {
     global $DB;
     if (count($arSelectFields) <= 0) {
         $arSelectFields = array("ID", "TITLE", "URL", "PREVIEW_TEXT", "BLOG_NAME", "POST_DATE", "BLOG_ID", "POST_ID");
     }
     // FIELDS -->
     $arFields = array("ID" => array("FIELD" => "C.ID", "TYPE" => "int"), "TITLE" => array("FIELD" => "C.TITLE", "TYPE" => "string"), "URL" => array("FIELD" => "C.URL", "TYPE" => "string"), "PREVIEW_TEXT" => array("FIELD" => "C.PREVIEW_TEXT", "TYPE" => "string"), "BLOG_NAME" => array("FIELD" => "C.BLOG_NAME", "TYPE" => "string"), "POST_DATE" => array("FIELD" => "C.POST_DATE", "TYPE" => "datetime"), "BLOG_ID" => array("FIELD" => "C.BLOG_ID", "TYPE" => "int"), "POST_ID" => array("FIELD" => "C.POST_ID", "TYPE" => "int"));
     // <-- FIELDS
     $arSqls = CBlog::PrepareSql($arFields, $arOrder, $arFilter, $arGroupBy, $arSelectFields);
     $arSqls["SELECT"] = str_replace("%%_DISTINCT_%%", "", $arSqls["SELECT"]);
     if (is_array($arGroupBy) && count($arGroupBy) == 0) {
         $strSql = "SELECT " . $arSqls["SELECT"] . " " . "FROM b_blog_trackback C " . "\t" . $arSqls["FROM"] . " ";
         if (strlen($arSqls["WHERE"]) > 0) {
             $strSql .= "WHERE " . $arSqls["WHERE"] . " ";
         }
         if (strlen($arSqls["GROUPBY"]) > 0) {
             $strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
         }
         //echo "!1!=".htmlspecialcharsbx($strSql)."<br>";
         $dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         if ($arRes = $dbRes->Fetch()) {
             return $arRes["CNT"];
         } else {
             return False;
         }
     }
     $strSql = "SELECT " . $arSqls["SELECT"] . " " . "FROM b_blog_trackback C " . "\t" . $arSqls["FROM"] . " ";
     if (strlen($arSqls["WHERE"]) > 0) {
         $strSql .= "WHERE " . $arSqls["WHERE"] . " ";
     }
     if (strlen($arSqls["GROUPBY"]) > 0) {
         $strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
     }
     if (strlen($arSqls["ORDERBY"]) > 0) {
         $strSql .= "ORDER BY " . $arSqls["ORDERBY"] . " ";
     }
     if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) <= 0) {
         $strSql_tmp = "SELECT COUNT('x') as CNT " . "FROM b_blog_trackback C " . "\t" . $arSqls["FROM"] . " ";
         if (strlen($arSqls["WHERE"]) > 0) {
             $strSql_tmp .= "WHERE " . $arSqls["WHERE"] . " ";
         }
         if (strlen($arSqls["GROUPBY"]) > 0) {
             $strSql_tmp .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
         }
         //echo "!2.1!=".htmlspecialcharsbx($strSql_tmp)."<br>";
         $dbRes = $DB->Query($strSql_tmp, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         $cnt = 0;
         if (strlen($arSqls["GROUPBY"]) <= 0) {
             if ($arRes = $dbRes->Fetch()) {
                 $cnt = $arRes["CNT"];
             }
         } else {
             // ТОЛЬКО ДЛЯ MYSQL!!! ДЛЯ ORACLE ДРУГОЙ КОД
             $cnt = $dbRes->SelectedRowsCount();
         }
         $dbRes = new CDBResult();
         //echo "!2.2!=".htmlspecialcharsbx($strSql)."<br>";
         $dbRes->NavQuery($strSql, $cnt, $arNavStartParams);
     } else {
         if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) > 0) {
             $strSql .= "LIMIT " . IntVal($arNavStartParams["nTopCount"]);
         }
         //echo "!3!=".htmlspecialcharsbx($strSql)."<br>";
         $dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     }
     return $dbRes;
 }
开发者ID:rasuldev,项目名称:torino,代码行数:68,代码来源:blog_trackback.php

示例7: GetList

 public static function GetList($arOrder = array("ID" => "DESC"), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array())
 {
     global $DB;
     if (count($arSelectFields) <= 0) {
         $arSelectFields = array("ID", "SMILE_TYPE", "TYPING", "IMAGE", "DESCRIPTION", "CLICKABLE", "SORT", "IMAGE_WIDTH", "IMAGE_HEIGHT");
     }
     // FIELDS -->
     $arFields = array("ID" => array("FIELD" => "B.ID", "TYPE" => "int"), "SMILE_TYPE" => array("FIELD" => "B.SMILE_TYPE", "TYPE" => "char"), "TYPING" => array("FIELD" => "B.TYPING", "TYPE" => "string"), "IMAGE" => array("FIELD" => "B.IMAGE", "TYPE" => "string"), "DESCRIPTION" => array("FIELD" => "B.DESCRIPTION", "TYPE" => "string"), "CLICKABLE" => array("FIELD" => "B.CLICKABLE", "TYPE" => "char"), "SORT" => array("FIELD" => "B.SORT", "TYPE" => "int"), "IMAGE_WIDTH" => array("FIELD" => "B.IMAGE_WIDTH", "TYPE" => "int"), "IMAGE_HEIGHT" => array("FIELD" => "B.IMAGE_HEIGHT", "TYPE" => "int"), "LANG_ID" => array("FIELD" => "BL.ID", "TYPE" => "int", "FROM" => "LEFT JOIN b_blog_smile_lang BL ON (B.ID = BL.SMILE_ID" . (isset($arFilter["LANG_LID"]) && strlen($arFilter["LANG_LID"]) > 0 ? " AND BL.LID = '" . $arFilter["LANG_LID"] . "'" : "") . ")"), "LANG_SMILE_ID" => array("FIELD" => "BL.SMILE_ID", "TYPE" => "int", "FROM" => "LEFT JOIN b_blog_smile_lang BL ON (B.ID = BL.SMILE_ID" . (isset($arFilter["LANG_LID"]) && strlen($arFilter["LANG_LID"]) > 0 ? " AND BL.LID = '" . $arFilter["LANG_LID"] . "'" : "") . ")"), "LANG_LID" => array("FIELD" => "BL.LID", "TYPE" => "string", "FROM" => "LEFT JOIN b_blog_smile_lang BL ON (B.ID = BL.SMILE_ID" . (isset($arFilter["LANG_LID"]) && strlen($arFilter["LANG_LID"]) > 0 ? " AND BL.LID = '" . $arFilter["LANG_LID"] . "'" : "") . ")"), "LANG_NAME" => array("FIELD" => "BL.NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_blog_smile_lang BL ON (B.ID = BL.SMILE_ID" . (isset($arFilter["LANG_LID"]) && strlen($arFilter["LANG_LID"]) > 0 ? " AND BL.LID = '" . $arFilter["LANG_LID"] . "'" : "") . ")"));
     // <-- FIELDS
     $arSqls = CBlog::PrepareSql($arFields, $arOrder, $arFilter, $arGroupBy, $arSelectFields);
     $arSqls["SELECT"] = str_replace("%%_DISTINCT_%%", "", $arSqls["SELECT"]);
     if (is_array($arGroupBy) && count($arGroupBy) == 0) {
         $strSql = "SELECT " . $arSqls["SELECT"] . " " . "FROM b_blog_smile B " . "\t" . $arSqls["FROM"] . " ";
         if (strlen($arSqls["WHERE"]) > 0) {
             $strSql .= "WHERE " . $arSqls["WHERE"] . " ";
         }
         if (strlen($arSqls["GROUPBY"]) > 0) {
             $strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
         }
         //echo "!1!=".htmlspecialcharsbx($strSql)."<br>";
         $dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         if ($arRes = $dbRes->Fetch()) {
             return $arRes["CNT"];
         } else {
             return False;
         }
     }
     $strSql = "SELECT " . $arSqls["SELECT"] . " " . "FROM b_blog_smile B " . "\t" . $arSqls["FROM"] . " ";
     if (strlen($arSqls["WHERE"]) > 0) {
         $strSql .= "WHERE " . $arSqls["WHERE"] . " ";
     }
     if (strlen($arSqls["GROUPBY"]) > 0) {
         $strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
     }
     if (strlen($arSqls["ORDERBY"]) > 0) {
         $strSql .= "ORDER BY " . $arSqls["ORDERBY"] . " ";
     }
     if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) <= 0) {
         $strSql_tmp = "SELECT COUNT('x') as CNT " . "FROM b_blog_smile B " . "\t" . $arSqls["FROM"] . " ";
         if (strlen($arSqls["WHERE"]) > 0) {
             $strSql_tmp .= "WHERE " . $arSqls["WHERE"] . " ";
         }
         if (strlen($arSqls["GROUPBY"]) > 0) {
             $strSql_tmp .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
         }
         //echo "!2.1!=".htmlspecialcharsbx($strSql_tmp)."<br>";
         $dbRes = $DB->Query($strSql_tmp, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         $cnt = 0;
         if (strlen($arSqls["GROUPBY"]) <= 0) {
             if ($arRes = $dbRes->Fetch()) {
                 $cnt = $arRes["CNT"];
             }
         } else {
             // ТОЛЬКО ДЛЯ MYSQL!!! ДЛЯ ORACLE ДРУГОЙ КОД
             $cnt = $dbRes->SelectedRowsCount();
         }
         $dbRes = new CDBResult();
         //echo "!2.2!=".htmlspecialcharsbx($strSql)."<br>";
         $dbRes->NavQuery($strSql, $cnt, $arNavStartParams);
     } else {
         if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) > 0) {
             $strSql .= "LIMIT " . IntVal($arNavStartParams["nTopCount"]);
         }
         //echo "!3!=".htmlspecialcharsbx($strSql)."<br>";
         $dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     }
     return $dbRes;
 }
开发者ID:rasuldev,项目名称:torino,代码行数:68,代码来源:smile.php

示例8: GetList

 function GetList($arOrder = array("ID" => "DESC"), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array())
 {
     global $DB, $USER_FIELD_MANAGER;
     $obUserFieldsSql = new CUserTypeSQL();
     $obUserFieldsSql->SetEntity("BLOG_BLOG", "B.ID");
     $obUserFieldsSql->SetSelect($arSelectFields);
     $obUserFieldsSql->SetFilter($arFilter);
     $obUserFieldsSql->SetOrder($arOrder);
     if (count($arSelectFields) <= 0) {
         $arSelectFields = array("ID", "NAME", "DESCRIPTION", "DATE_CREATE", "DATE_UPDATE", "ACTIVE", "OWNER_ID", "URL", "REAL_URL", "GROUP_ID", "ENABLE_COMMENTS", "ENABLE_IMG_VERIF", "EMAIL_NOTIFY", "ENABLE_RSS", "LAST_POST_ID", "LAST_POST_DATE", "AUTO_GROUPS", "ALLOW_HTML", "SOCNET_GROUP_ID");
     }
     if (in_array("*", $arSelectFields)) {
         $arSelectFields = array("ID", "NAME", "DESCRIPTION", "DATE_CREATE", "DATE_UPDATE", "ACTIVE", "OWNER_ID", "SOCNET_GROUP_ID", "URL", "REAL_URL", "GROUP_ID", "ENABLE_COMMENTS", "ENABLE_IMG_VERIF", "EMAIL_NOTIFY", "ENABLE_RSS", "ALLOW_HTML", "LAST_POST_ID", "LAST_POST_DATE", "AUTO_GROUPS", "SEARCH_INDEX", "USE_SOCNET", "OWNER_LOGIN", "OWNER_NAME", "OWNER_LAST_NAME", "OWNER_EMAIL", "OWNER", "GROUP_NAME", "GROUP_SITE_ID", "BLOG_USER_ALIAS", "BLOG_USER_AVATAR");
     }
     // FIELDS -->
     $arFields = array("ID" => array("FIELD" => "B.ID", "TYPE" => "int"), "NAME" => array("FIELD" => "B.NAME", "TYPE" => "string"), "DESCRIPTION" => array("FIELD" => "B.DESCRIPTION", "TYPE" => "string"), "DATE_CREATE" => array("FIELD" => "B.DATE_CREATE", "TYPE" => "datetime"), "DATE_UPDATE" => array("FIELD" => "B.DATE_UPDATE", "TYPE" => "datetime"), "ACTIVE" => array("FIELD" => "B.ACTIVE", "TYPE" => "char"), "OWNER_ID" => array("FIELD" => "B.OWNER_ID", "TYPE" => "int"), "SOCNET_GROUP_ID" => array("FIELD" => "B.SOCNET_GROUP_ID", "TYPE" => "int"), "URL" => array("FIELD" => "B.URL", "TYPE" => "string"), "REAL_URL" => array("FIELD" => "B.REAL_URL", "TYPE" => "string"), "GROUP_ID" => array("FIELD" => "B.GROUP_ID", "TYPE" => "int"), "ENABLE_COMMENTS" => array("FIELD" => "B.ENABLE_COMMENTS", "TYPE" => "char"), "ENABLE_IMG_VERIF" => array("FIELD" => "B.ENABLE_IMG_VERIF", "TYPE" => "char"), "EMAIL_NOTIFY" => array("FIELD" => "B.EMAIL_NOTIFY", "TYPE" => "char"), "ENABLE_RSS" => array("FIELD" => "B.ENABLE_RSS", "TYPE" => "char"), "ALLOW_HTML" => array("FIELD" => "B.ALLOW_HTML", "TYPE" => "char"), "LAST_POST_ID" => array("FIELD" => "B.LAST_POST_ID", "TYPE" => "int"), "LAST_POST_DATE" => array("FIELD" => "B.LAST_POST_DATE", "TYPE" => "datetime"), "AUTO_GROUPS" => array("FIELD" => "B.AUTO_GROUPS", "TYPE" => "string"), "SEARCH_INDEX" => array("FIELD" => "B.SEARCH_INDEX", "TYPE" => "char"), "USE_SOCNET" => array("FIELD" => "B.USE_SOCNET", "TYPE" => "char"), "OWNER_LOGIN" => array("FIELD" => "U.LOGIN", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U ON (B.OWNER_ID = U.ID)"), "OWNER_NAME" => array("FIELD" => "U.NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U ON (B.OWNER_ID = U.ID)"), "OWNER_LAST_NAME" => array("FIELD" => "U.LAST_NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U ON (B.OWNER_ID = U.ID)"), "OWNER_SECOND_NAME" => array("FIELD" => "U.SECOND_NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U ON (B.OWNER_ID = U.ID)"), "OWNER_EMAIL" => array("FIELD" => "U.EMAIL", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U ON (B.OWNER_ID = U.ID)"), "OWNER" => array("FIELD" => "U.LOGIN,U.NAME,U.LAST_NAME,U.EMAIL,U.ID", "WHERE_ONLY" => "Y", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U ON (B.OWNER_ID = U.ID)"), "GROUP_NAME" => array("FIELD" => "G.NAME", "TYPE" => "string", "FROM" => "INNER JOIN b_blog_group G ON (B.GROUP_ID = G.ID)"), "GROUP_SITE_ID" => array("FIELD" => "G.SITE_ID", "TYPE" => "string", "FROM" => "INNER JOIN b_blog_group G ON (B.GROUP_ID = G.ID)"), "BLOG_USER_ALIAS" => array("FIELD" => "BU.ALIAS", "TYPE" => "string", "FROM" => "LEFT JOIN b_blog_user BU ON (B.OWNER_ID = BU.USER_ID)"), "BLOG_USER_AVATAR" => array("FIELD" => "BU.AVATAR", "TYPE" => "int", "FROM" => "LEFT JOIN b_blog_user BU ON (B.OWNER_ID = BU.USER_ID)"), "SOCNET_BLOG_READ" => array("FIELD" => "BS.BLOG_ID", "TYPE" => "int", "FROM" => "INNER JOIN b_blog_socnet BS ON (B.ID = BS.BLOG_ID)"), "PERMS" => array());
     // <-- FIELDS
     if ($GLOBALS["USER"]->IsAuthorized()) {
         $arFields["PERMS"] = array("FIELD" => "bugp.PERMS", "TYPE" => "char", "FROM" => "INNER JOIN b_blog_user_group_perms bugp ON (B.ID = bugp.BLOG_ID)\n\t\t\t\t\t\t\tINNER JOIN b_blog_user2user_group bug ON (B.ID = bug.BLOG_ID AND bugp.USER_GROUP_ID = bug.USER_GROUP_ID)");
         $arFields["PERMS_TYPE"] = array("FIELD" => "bugp.PERMS_TYPE", "TYPE" => "char", "FROM" => "INNER JOIN b_blog_user_group_perms bugp ON (B.ID = bugp.BLOG_ID)\n\t\t\t\t\t\t\tINNER JOIN b_blog_user2user_group bug ON (B.ID = bug.BLOG_ID AND bugp.USER_GROUP_ID = bug.USER_GROUP_ID)");
         $arFields["PERMS_USER_ID"] = array("FIELD" => "bug.USER_ID", "TYPE" => "int", "FROM" => "INNER JOIN b_blog_user_group_perms bugp ON (B.ID = bugp.BLOG_ID)\n\t\t\t\t\t\t\tINNER JOIN b_blog_user2user_group bug ON (B.ID = bug.BLOG_ID AND bugp.USER_GROUP_ID = bug.USER_GROUP_ID)");
         $arFields["PERMS_POST_ID"] = array("FIELD" => "bugp.POST_ID", "TYPE" => "int", "FROM" => "INNER JOIN b_blog_user_group_perms bugp ON (B.ID = bugp.BLOG_ID)\n\t\t\t\t\t\t\tINNER JOIN b_blog_user2user_group bug ON (B.ID = bug.BLOG_ID AND bugp.USER_GROUP_ID = bug.USER_GROUP_ID)");
     }
     $arSqls = CBlog::PrepareSql($arFields, $arOrder, $arFilter, $arGroupBy, $arSelectFields, $obUserFieldsSql);
     $arSqls["SELECT"] = str_replace("%%_DISTINCT_%%", "", $arSqls["SELECT"]);
     $r = $obUserFieldsSql->GetFilter();
     if (strlen($r) > 0) {
         $strSqlUFFilter = " (" . $r . ") ";
     }
     if (is_array($arGroupBy) && count($arGroupBy) == 0) {
         $strSql = "SELECT " . $arSqls["SELECT"] . " " . $obUserFieldsSql->GetSelect() . " " . "FROM b_blog B " . "\t" . $arSqls["FROM"] . " " . $obUserFieldsSql->GetJoin("B.ID") . " ";
         if (strlen($arSqls["WHERE"]) > 0) {
             $strSql .= "WHERE " . $arSqls["WHERE"] . " ";
         }
         if (strlen($arSqls["WHERE"]) > 0 && strlen($strSqlUFFilter) > 0) {
             $strSql .= " AND " . $strSqlUFFilter . " ";
         } elseif (strlen($arSqls["WHERE"]) <= 0 && strlen($strSqlUFFilter) > 0) {
             $strSql .= " WHERE " . $strSqlUFFilter . " ";
         }
         if (strlen($arSqls["GROUPBY"]) > 0) {
             $strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
         }
         //echo "!1!=".htmlspecialcharsbx($strSql)."<br>";
         $dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         if ($arRes = $dbRes->Fetch()) {
             return $arRes["CNT"];
         } else {
             return False;
         }
     }
     $strSql = "SELECT " . $arSqls["SELECT"] . " " . $obUserFieldsSql->GetSelect() . " " . "FROM b_blog B " . "\t" . $arSqls["FROM"] . " " . $obUserFieldsSql->GetJoin("B.ID") . " ";
     if (strlen($arSqls["WHERE"]) > 0) {
         $strSql .= "WHERE " . $arSqls["WHERE"] . " ";
     }
     if (strlen($arSqls["WHERE"]) > 0 && strlen($strSqlUFFilter) > 0) {
         $strSql .= " AND " . $strSqlUFFilter . " ";
     } elseif (strlen($arSqls["WHERE"]) <= 0 && strlen($strSqlUFFilter) > 0) {
         $strSql .= " WHERE " . $strSqlUFFilter . " ";
     }
     if (strlen($arSqls["GROUPBY"]) > 0) {
         $strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
     }
     if (strlen($arSqls["ORDERBY"]) > 0) {
         $strSql .= "ORDER BY " . $arSqls["ORDERBY"] . " ";
     }
     if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) <= 0) {
         $strSql_tmp = "SELECT COUNT('x') as CNT " . "FROM b_blog B " . "\t" . $arSqls["FROM"] . " " . $obUserFieldsSql->GetJoin("B.ID") . " ";
         if (strlen($arSqls["WHERE"]) > 0) {
             $strSql_tmp .= "WHERE " . $arSqls["WHERE"] . " ";
         }
         if (strlen($arSqls["WHERE"]) > 0 && strlen($strSqlUFFilter) > 0) {
             $strSql_tmp .= " AND " . $strSqlUFFilter . " ";
         } elseif (strlen($arSqls["WHERE"]) <= 0 && strlen($strSqlUFFilter) > 0) {
             $strSql_tmp .= " WHERE " . $strSqlUFFilter . " ";
         }
         if (strlen($arSqls["GROUPBY"]) > 0) {
             $strSql_tmp .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
         }
         //echo "!2.1!=".htmlspecialcharsbx($strSql_tmp)."<br>";
         $dbRes = $DB->Query($strSql_tmp, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         $cnt = 0;
         if (strlen($arSqls["GROUPBY"]) <= 0) {
             if ($arRes = $dbRes->Fetch()) {
                 $cnt = $arRes["CNT"];
             }
         } else {
             $cnt = $dbRes->SelectedRowsCount();
         }
         $dbRes = new CDBResult();
         //echo "!2.2!=".htmlspecialcharsbx($strSql)."<br>";
         $dbRes->SetUserFields($USER_FIELD_MANAGER->GetUserFields("BLOG_BLOG"));
         $dbRes->NavQuery($strSql, $cnt, $arNavStartParams);
     } else {
         if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) > 0) {
             $strSql .= "LIMIT " . IntVal($arNavStartParams["nTopCount"]);
         }
         //echo "!3!=".htmlspecialcharsbx($strSql)."<br>";
         $dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         $dbRes->SetUserFields($USER_FIELD_MANAGER->GetUserFields("BLOG_BLOG"));
     }
//.........这里部分代码省略.........
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:101,代码来源:blog.php

示例9: GetList

 function GetList($arOrder = array("ID" => "DESC"), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array())
 {
     global $DB;
     if (count($arSelectFields) <= 0) {
         $arSelectFields = array("ID", "FILE_ID", "POST_ID", "BLOG_ID", "USER_ID", "TITLE", "TIMESTAMP_X", "IMAGE_SIZE");
     }
     // FIELDS -->
     $arFields = array("ID" => array("FIELD" => "G.ID", "TYPE" => "int"), "FILE_ID" => array("FIELD" => "G.FILE_ID", "TYPE" => "int"), "POST_ID" => array("FIELD" => "G.POST_ID", "TYPE" => "int"), "BLOG_ID" => array("FIELD" => "G.BLOG_ID", "TYPE" => "int"), "USER_ID" => array("FIELD" => "G.USER_ID", "TYPE" => "int"), "TITLE" => array("FIELD" => "G.TITLE", "TYPE" => "string"), "TIMESTAMP_X" => array("FIELD" => "G.TIMESTAMP_X", "TYPE" => "datetime"), "IMAGE_SIZE" => array("FIELD" => "G.IMAGE_SIZE", "TYPE" => "int"), "IS_COMMENT" => array("FIELD" => "G.IS_COMMENT", "TYPE" => "string"), "COMMENT_ID" => array("FIELD" => "G.COMMENT_ID", "TYPE" => "int"));
     // <-- FIELDS
     $arSqls = CBlog::PrepareSql($arFields, $arOrder, $arFilter, $arGroupBy, $arSelectFields);
     $arSqls["SELECT"] = str_replace("%%_DISTINCT_%%", "", $arSqls["SELECT"]);
     if (is_array($arGroupBy) && count($arGroupBy) == 0) {
         $strSql = "SELECT " . $arSqls["SELECT"] . " " . "FROM b_blog_image G " . "\t" . $arSqls["FROM"] . " ";
         if (strlen($arSqls["WHERE"]) > 0) {
             $strSql .= "WHERE " . $arSqls["WHERE"] . " ";
         }
         if (strlen($arSqls["GROUPBY"]) > 0) {
             $strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
         }
         //echo "!1!=".htmlspecialcharsbx($strSql)."<br>";
         $dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         if ($arRes = $dbRes->Fetch()) {
             return $arRes["CNT"];
         } else {
             return False;
         }
     }
     $strSql = "SELECT " . $arSqls["SELECT"] . " " . "FROM b_blog_image G " . "\t" . $arSqls["FROM"] . " ";
     if (strlen($arSqls["WHERE"]) > 0) {
         $strSql .= "WHERE " . $arSqls["WHERE"] . " ";
     }
     if (strlen($arSqls["GROUPBY"]) > 0) {
         $strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
     }
     if (strlen($arSqls["ORDERBY"]) > 0) {
         $strSql .= "ORDER BY " . $arSqls["ORDERBY"] . " ";
     }
     if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) <= 0) {
         $strSql_tmp = "SELECT COUNT('x') as CNT " . "FROM b_blog_image G " . "\t" . $arSqls["FROM"] . " ";
         if (strlen($arSqls["WHERE"]) > 0) {
             $strSql_tmp .= "WHERE " . $arSqls["WHERE"] . " ";
         }
         if (strlen($arSqls["GROUPBY"]) > 0) {
             $strSql_tmp .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
         }
         //echo "!2.1!=".htmlspecialcharsbx($strSql_tmp)."<br>";
         $dbRes = $DB->Query($strSql_tmp, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         $cnt = 0;
         if (strlen($arSqls["GROUPBY"]) <= 0) {
             if ($arRes = $dbRes->Fetch()) {
                 $cnt = $arRes["CNT"];
             }
         } else {
             $cnt = $dbRes->SelectedRowsCount();
         }
         $dbRes = new CDBResult();
         //echo "!2.2!=".htmlspecialcharsbx($strSql)."<br>";
         $dbRes->NavQuery($strSql, $cnt, $arNavStartParams);
     } else {
         if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) > 0) {
             $strSql .= "LIMIT " . IntVal($arNavStartParams["nTopCount"]);
         }
         //echo "!3!=".htmlspecialcharsbx($strSql)."<br>";
         $dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     }
     return $dbRes;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:67,代码来源:blog_image.php

示例10: GetList

 public static function GetList($arOrder = array("ID" => "DESC"), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array())
 {
     global $DB;
     if (count($arSelectFields) <= 0) {
         $arSelectFields = array("ID", "BLOG_ID", "USER_ID");
     }
     // FIELDS -->
     $arFields = array("ID" => array("FIELD" => "C.ID", "TYPE" => "int"), "BLOG_ID" => array("FIELD" => "C.BLOG_ID", "TYPE" => "int"), "USER_ID" => array("FIELD" => "C.USER_ID", "TYPE" => "int"), "USER_LOGIN" => array("FIELD" => "U.LOGIN", "TYPE" => "string", "FROM" => "INNER JOIN b_user U ON (C.USER_ID = U.ID)"), "USER_NAME" => array("FIELD" => "U.NAME", "TYPE" => "string", "FROM" => "INNER JOIN b_user U ON (C.USER_ID = U.ID)"), "USER_LAST_NAME" => array("FIELD" => "U.LAST_NAME", "TYPE" => "string", "FROM" => "INNER JOIN b_user U ON (C.USER_ID = U.ID)"), "USER_SECOND_NAME" => array("FIELD" => "U.SECOND_NAME", "TYPE" => "string", "FROM" => "INNER JOIN b_user U ON (C.USER_ID = U.ID)"), "USER_EMAIL" => array("FIELD" => "U.EMAIL", "TYPE" => "string", "FROM" => "INNER JOIN b_user U ON (C.USER_ID = U.ID)"), "USER" => array("FIELD" => "U.LOGIN,U.NAME,U.LAST_NAME,U.SECOND_NAME,U.EMAIL,U.ID", "WHERE_ONLY" => "Y", "TYPE" => "string", "FROM" => "INNER JOIN b_user U ON (C.USER_ID = U.ID)"), "BLOG_USER_ID" => array("FIELD" => "BU.ID", "TYPE" => "int", "FROM" => "LEFT JOIN b_blog_user BU ON (C.USER_ID = BU.USER_ID)"), "BLOG_USER_ALIAS" => array("FIELD" => "BU.ALIAS", "TYPE" => "string", "FROM" => "LEFT JOIN b_blog_user BU ON (C.USER_ID = BU.USER_ID)"));
     // <-- FIELDS
     $arSqls = CBlog::PrepareSql($arFields, $arOrder, $arFilter, $arGroupBy, $arSelectFields);
     $arSqls["SELECT"] = str_replace("%%_DISTINCT_%%", "", $arSqls["SELECT"]);
     if (is_array($arGroupBy) && count($arGroupBy) == 0) {
         $strSql = "SELECT " . $arSqls["SELECT"] . " " . "FROM b_blog_user2blog C " . "\t" . $arSqls["FROM"] . " ";
         if (strlen($arSqls["WHERE"]) > 0) {
             $strSql .= "WHERE " . $arSqls["WHERE"] . " ";
         }
         if (strlen($arSqls["GROUPBY"]) > 0) {
             $strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
         }
         //echo "!1!=".htmlspecialcharsbx($strSql)."<br>";
         $dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         if ($arRes = $dbRes->Fetch()) {
             return $arRes["CNT"];
         } else {
             return False;
         }
     }
     $strSql = "SELECT " . $arSqls["SELECT"] . " " . "FROM b_blog_user2blog C " . "\t" . $arSqls["FROM"] . " ";
     if (strlen($arSqls["WHERE"]) > 0) {
         $strSql .= "WHERE " . $arSqls["WHERE"] . " ";
     }
     if (strlen($arSqls["GROUPBY"]) > 0) {
         $strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
     }
     if (strlen($arSqls["ORDERBY"]) > 0) {
         $strSql .= "ORDER BY " . $arSqls["ORDERBY"] . " ";
     }
     if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) <= 0) {
         $strSql_tmp = "SELECT COUNT('x') as CNT " . "FROM b_blog_user2blog C " . "\t" . $arSqls["FROM"] . " ";
         if (strlen($arSqls["WHERE"]) > 0) {
             $strSql_tmp .= "WHERE " . $arSqls["WHERE"] . " ";
         }
         if (strlen($arSqls["GROUPBY"]) > 0) {
             $strSql_tmp .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
         }
         //echo "!2.1!=".htmlspecialcharsbx($strSql_tmp)."<br>";
         $dbRes = $DB->Query($strSql_tmp, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         $cnt = 0;
         if (strlen($arSqls["GROUPBY"]) <= 0) {
             if ($arRes = $dbRes->Fetch()) {
                 $cnt = $arRes["CNT"];
             }
         } else {
             // ТОЛЬКО ДЛЯ MYSQL!!! ДЛЯ ORACLE ДРУГОЙ КОД
             $cnt = $dbRes->SelectedRowsCount();
         }
         $dbRes = new CDBResult();
         //echo "!2.2!=".htmlspecialcharsbx($strSql)."<br>";
         $dbRes->NavQuery($strSql, $cnt, $arNavStartParams);
     } else {
         if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) > 0) {
             $strSql .= "LIMIT " . IntVal($arNavStartParams["nTopCount"]);
         }
         //echo "!3!=".htmlspecialcharsbx($strSql)."<br>";
         $dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     }
     return $dbRes;
 }
开发者ID:rasuldev,项目名称:torino,代码行数:68,代码来源:blog_candid.php

示例11: GetList

 function GetList($arOrder = array("ID" => "DESC"), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array())
 {
     global $DB;
     if (count($arSelectFields) <= 0) {
         $arSelectFields = array("ID", "SITE_ID", "PATH", "TYPE");
     }
     // FIELDS -->
     $arFields = array("ID" => array("FIELD" => "P.ID", "TYPE" => "int"), "SITE_ID" => array("FIELD" => "P.SITE_ID", "TYPE" => "string"), "PATH" => array("FIELD" => "P.PATH", "TYPE" => "string"), "TYPE" => array("FIELD" => "P.TYPE", "TYPE" => "string"));
     // <-- FIELDS
     $arSqls = CBlog::PrepareSql($arFields, $arOrder, $arFilter, $arGroupBy, $arSelectFields);
     $arSqls["SELECT"] = str_replace("%%_DISTINCT_%%", "", $arSqls["SELECT"]);
     if (is_array($arGroupBy) && count($arGroupBy) == 0) {
         $strSql = "SELECT " . $arSqls["SELECT"] . " " . "FROM b_blog_site_path P " . "\t" . $arSqls["FROM"] . " ";
         if (strlen($arSqls["WHERE"]) > 0) {
             $strSql .= "WHERE " . $arSqls["WHERE"] . " ";
         }
         if (strlen($arSqls["GROUPBY"]) > 0) {
             $strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
         }
         //echo "!1!=".htmlspecialcharsbx($strSql)."<br>";
         $dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         if ($arRes = $dbRes->Fetch()) {
             return $arRes["CNT"];
         } else {
             return False;
         }
     }
     $strSql = "SELECT " . $arSqls["SELECT"] . " " . "FROM b_blog_site_path P " . "\t" . $arSqls["FROM"] . " ";
     if (strlen($arSqls["WHERE"]) > 0) {
         $strSql .= "WHERE " . $arSqls["WHERE"] . " ";
     }
     if (strlen($arSqls["GROUPBY"]) > 0) {
         $strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
     }
     if (strlen($arSqls["ORDERBY"]) > 0) {
         $strSql .= "ORDER BY " . $arSqls["ORDERBY"] . " ";
     }
     if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) <= 0) {
         $strSql_tmp = "SELECT COUNT('x') as CNT " . "FROM b_blog_site_path P " . "\t" . $arSqls["FROM"] . " ";
         if (strlen($arSqls["WHERE"]) > 0) {
             $strSql_tmp .= "WHERE " . $arSqls["WHERE"] . " ";
         }
         if (strlen($arSqls["GROUPBY"]) > 0) {
             $strSql_tmp .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
         }
         //echo "!2.1!=".htmlspecialcharsbx($strSql_tmp)."<br>";
         $dbRes = $DB->Query($strSql_tmp, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         $cnt = 0;
         if (strlen($arSqls["GROUPBY"]) <= 0) {
             if ($arRes = $dbRes->Fetch()) {
                 $cnt = $arRes["CNT"];
             }
         } else {
             // рнкэйн дкъ MYSQL!!! дкъ ORACLE дпсцни йнд
             $cnt = $dbRes->SelectedRowsCount();
         }
         $dbRes = new CDBResult();
         //echo "!2.2!=".htmlspecialcharsbx($strSql)."<br>";
         $dbRes->NavQuery($strSql, $cnt, $arNavStartParams);
     } else {
         if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) > 0) {
             $strSql .= "LIMIT " . IntVal($arNavStartParams["nTopCount"]);
         }
         //echo "!3!=".htmlspecialcharsbx($strSql)."<br>";
         $dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     }
     return $dbRes;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:68,代码来源:blog_site_path.php


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