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


PHP CForumNew::GetFilterOperation方法代码示例

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


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

示例1: GetListEx

 public static function GetListEx($arOrder = array("ID" => "ASC"), $arFilter = array(), $arAddParams = array())
 {
     global $DB;
     $arSqlSearch = array();
     $arSqlFrom = array();
     $arSqlOrder = array();
     $strSqlSearch = "";
     $strSqlFrom = "";
     $strSqlOrder = "";
     $arFilter = is_array($arFilter) ? $arFilter : array();
     foreach ($arFilter as $key => $val) {
         $key_res = CForumNew::GetFilterOperation($key);
         $key = strtoupper($key_res["FIELD"]);
         $strNegative = $key_res["NEGATIVE"];
         $strOperation = $key_res["OPERATION"];
         switch ($key) {
             case "TOPIC_ID":
             case "FORUM_ID":
                 if (intVal($val) <= 0) {
                     $arSqlSearch[] = ($strNegative == "Y" ? "NOT" : "") . "(FSTAT." . $key . " IS NULL OR FSTAT." . $key . "<=0)";
                 } else {
                     $arSqlSearch[] = ($strNegative == "Y" ? " FSTAT." . $key . " IS NULL OR NOT " : "") . "(FSTAT." . $key . " " . $strOperation . " " . intVal($val) . ")";
                 }
                 break;
             case "SITE_ID":
                 $bOrNull = false;
                 if (is_array($val)) {
                     $res = array();
                     foreach ($val as $v) {
                         $v = trim($v);
                         if ($v == "NULL") {
                             $bOrNull = true;
                         } elseif (!empty($v)) {
                             $res[] = "'" . $DB->ForSql($v) . "'";
                         }
                     }
                     $val = !empty($res) ? implode(", ", $res) : "";
                     $strOperation = !empty($res) ? "IN" : $strOperation;
                 } else {
                     $val = "'" . $DB->ForSql($val) . "'";
                 }
                 if (strlen($val) <= 0) {
                     $arSqlSearch[] = ($strNegative == "Y" ? "NOT" : "") . "(FSTAT." . $key . " IS NULL OR LENGTH(FSTAT." . $key . ")<=0)";
                 } elseif ($strOperation == "IN") {
                     $arSqlSearch[] = ($strNegative == "Y" ? " FSTAT." . $key . " IS NULL OR NOT " : "") . "(FSTAT." . $key . " IN (" . $val . ")" . ($bOrNull ? " OR (FSTAT." . $key . " IS NULL OR LENGTH(FSTAT." . $key . ")<=0)" : "") . ")";
                 } else {
                     $arSqlSearch[] = ($strNegative == "Y" ? " FSTAT." . $key . " IS NULL OR NOT " : "") . "(FSTAT." . $key . " " . $strOperation . " " . $val . ")";
                 }
                 break;
             case "LAST_VISIT":
                 if (strLen($val) <= 0) {
                     $arSqlSearch[] = ($strNegative == "Y" ? "NOT" : "") . "(FSTAT." . $key . " IS NULL)";
                 } else {
                     $arSqlSearch[] = ($strNegative == "Y" ? " FSTAT." . $key . " IS NULL OR NOT " : "") . "(FSTAT." . $key . " " . $strOperation . " " . $DB->CharToDateFunction($DB->ForSql($val), "FULL") . ")";
                 }
                 break;
             case "PERIOD":
                 if (strLen($val) <= 0) {
                     $arSqlSearch[] = ($strNegative == "Y" ? "NOT" : "") . "(FSTAT.LAST_VISIT IS NULL)";
                 } else {
                     $arSqlSearch[] = ($strNegative == "Y" ? " FSTAT.LAST_VISIT IS NULL OR NOT " : "") . "(FROM_UNIXTIME(UNIX_TIMESTAMP(CURRENT_TIMESTAMP) - " . intVal($val) . ") " . $strOperation . "  FSTAT.LAST_VISIT)";
                 }
                 break;
             case "HIDE_FROM_ONLINE":
                 $arSqlFrom["FU"] = "LEFT JOIN b_forum_user FU ON (FSTAT.USER_ID=FU.USER_ID)";
                 if (strLen($val) <= 0) {
                     $arSqlSearch[] = ($strNegative == "Y" ? "NOT" : "") . "(FU." . $key . " IS NULL OR LENGTH(FU." . $key . ")<=0)";
                 } else {
                     $arSqlSearch[] = ($strNegative == "Y" ? " FU." . $key . " IS NULL OR NOT " : "") . "(((FU." . $key . " " . $strOperation . " '" . $DB->ForSql($val) . "' ) AND (FSTAT.USER_ID > 0)) OR (FSTAT.USER_ID <= 0))";
                 }
                 break;
                 break;
             case "ACTIVE":
                 $arSqlFrom["U"] = "LEFT JOIN b_user U ON (FSTAT.USER_ID=U.ID)";
                 $arSqlSearch[] = ($strNegative == "Y" ? " U." . $key . " IS NULL OR NOT " : "") . "(FSTAT.USER_ID = 0 OR U.ACTIVE = 'Y')";
                 break;
         }
     }
     if (!empty($arSqlSearch)) {
         $strSqlSearch = " AND " . implode(" AND ", $arSqlSearch) . " ";
     }
     if (!empty($arSqlFrom)) {
         $strSqlFrom = implode("\n", $arSqlFrom);
     }
     foreach ($arOrder as $by => $order) {
         $by = strtoupper($by);
         $order = strtoupper($order);
         $order = $order != "ASC" ? $order = "DESC" : "ASC";
         if ($by == "USER_ID") {
             $arSqlOrder[] = " FSTAT.USER_ID " . $order . " ";
         }
     }
     DelDuplicateSort($arSqlOrder);
     if (count($arSqlOrder) > 0) {
         $strSqlOrder = " ORDER BY " . implode(", ", $arSqlOrder);
     }
     $strSql = "SELECT FSTAT.USER_ID, FSTAT.IP_ADDRESS, FSTAT.PHPSESSID, \n" . "\t" . $DB->DateToCharFunction("FSTAT.LAST_VISIT", "FULL") . " AS LAST_VISIT, \n" . "\tFSTAT.FORUM_ID, FSTAT.TOPIC_ID \n" . "FROM b_forum_stat FSTAT " . $strSqlFrom . "\n" . "WHERE 1=1 " . $strSqlSearch . "\n" . $strSqlOrder;
     if (is_set($arFilter, "COUNT_GUEST")) {
         $strSql = "SELECT FST.*, FU.*, FSTAT.IP_ADDRESS, FSTAT.PHPSESSID, \n" . "\t" . $DB->DateToCharFunction("FSTAT.LAST_VISIT", "FULL") . " AS LAST_VISIT, \n" . "\tFSTAT.FORUM_ID, FSTAT.TOPIC_ID, \n" . "\tU.LOGIN, U.NAME, U.SECOND_NAME, U.LAST_NAME, \n" . "\t" . (!empty($arAddParams["sNameTemplate"]) ? CForumUser::GetFormattedNameFieldsForSelect(array_merge($arAddParams, array("sUserTablePrefix" => "U.", "sForumUserTablePrefix" => "FU.", "sFieldName" => "SHOW_NAME")), false) : "FSTAT.SHOW_NAME") . "\n " . " FROM ( " . " SELECT FSTAT.USER_ID, MAX(FSTAT.ID) FST_ID, COUNT(FSTAT.PHPSESSID) COUNT_USER " . " FROM b_forum_stat FSTAT " . $strSqlFrom . " WHERE 1=1 " . $strSqlSearch . " GROUP BY FSTAT.USER_ID" . ") FST " . "LEFT JOIN b_forum_stat FSTAT ON (FST.FST_ID = FSTAT.ID) " . "LEFT JOIN b_forum_user FU ON (FST.USER_ID = FU.USER_ID) " . "LEFT JOIN b_user U ON (FST.USER_ID = U.ID) " . $strSqlOrder;
     }
//.........这里部分代码省略.........
开发者ID:rasuldev,项目名称:torino,代码行数:101,代码来源:user.php

示例2: GetList

	function GetList($arOrder = Array("ID"=>"ASC"), $arFilter = Array(), $iNum = 0, $arAddParams = array())
	{
		global $DB;
		$arSqlSearch = array();
		$arSqlOrder = array();
		$strSqlSearch = "";
		$strSqlOrder = "";
		$iCnt = 0;
		$iNum = intVal($iNum);
		$arFilter = (is_array($arFilter) ? $arFilter : array());
		$arAddParams = (is_array($arAddParams) ? $arAddParams : array());
		if (intVal($arAddParams["nTopCount"]) > 0)
			unset($arAddParams["bDescPageNumbering"]);

		foreach ($arFilter as $key => $val)
		{
			$key_res = CForumNew::GetFilterOperation($key);
			$key = strtoupper($key_res["FIELD"]);
			$strNegative = $key_res["NEGATIVE"];
			$strOperation = $key_res["OPERATION"];

			switch ($key)
			{
				case "PARAM1":
				case "AUTHOR_NAME":
				case "POST_MESSAGE_CHECK":
				case "APPROVED":
					if (strlen($val)<=0)
						$arSqlSearch[] = ($strNegative=="Y"?"NOT":"")."(FM.".$key." IS NULL OR LENGTH(FM.".$key.")<=0)";
					else
						$arSqlSearch[] = ($strNegative=="Y"?" FM.".$key." IS NULL OR NOT ":"")."(FM.".$key." ".$strOperation." '".$DB->ForSql($val)."' )";
					break;
				// to table b_forum_message
				case "APPROVED_AND_MINE":
					if ($val >= 0)
						$arSqlSearch[] = "(FM.APPROVED='Y' OR (FM.APPROVED != 'Y' AND FM.AUTHOR_ID=".intval($val)."))";
					else
						$arSqlSearch[] = "(FM.APPROVED='Y')";
					break;
				case "PARAM2":
				case "FORUM_ID":
				case "TOPIC_ID":
				case "AUTHOR_ID":
					if (($strOperation!="IN") && (intVal($val) > 0))
						$arSqlSearch[] = ($strNegative=="Y"?" FM.".$key." IS NULL OR NOT ":"")."(FM.".$key." ".$strOperation." ".intVal($val)." )";
					elseif ($strOperation == "IN" && (is_array($val) && array_sum($val) > 0 || is_string($val) && strlen($val) > 0))
					{
						if (is_array($val))
						{
							$val_int = array();
							foreach ($val as $v)
								$val_int[] = intVal($v);
							$val = implode(", ", $val_int);
						}
						$arSqlSearch[] = ($strNegative=="Y"?" NOT ":"")."(FM.".$key." IN (".$DB->ForSql($val).") )";
					}
					else
						$arSqlSearch[] = ($strNegative=="Y"?"NOT":"")."(FM.".$key." IS NULL OR FM.".$key."<=0)";
					break;
				// to table b_forum_file
				case "FILE_FORUM_ID":
				case "FILE_TOPIC_ID":
				case "FILE_MESSAGE_ID":
					$key = substr($key, 5);
					if ($strOperation != "IN" && intVal($val) > 0)
					{
						$res = ($strNegative=="Y"?" FF.".$key." IS NULL OR NOT ":"")."(FF.".$key." ".$strOperation." ".intVal($val)." ) OR ".
							"".($strNegative=="Y"?"NOT":"")."(FF.".$key." IS NULL OR FF.".$key."<=0)";
						$arSqlSearch[] = $res;
						break;
					}
					elseif ($strOperation == "IN" && (is_array($val) && array_sum($val) > 0 || is_string($val) && strlen($val) > 0))
					{
						$val = (!is_array($val) ? explode(",", $val) : $val);
						$val_int = array();
						foreach ($val as $k => $v):
							$val_int[] = intVal($v);
						endforeach;
						$val = implode(",", $val_int);
						if (strLen($val) > 0)
						{
							$arSqlSearch[] = ($strNegative=="Y"?" NOT ":"")."(FF.".$key." IN (".$DB->ForSql($val).") )";
							break;
						}
					}
					$arSqlSearch[] = ($strNegative=="Y"?"NOT":"")."(FF.".$key." IS NULL OR FF.".$key."<=0)";
					break;
				case "FILE_ID":
				case "MESSAGE_ID":
				case "USER_ID":
					if (($strOperation!="IN") && (intVal($val) > 0 || $val === 0))
					{
						$arSqlSearch[] = ($strNegative=="Y"?" FF.".$key." IS NULL OR NOT ":"")."(FF.".$key." ".$strOperation." ".intVal($val)." )";
						break;
					}
					elseif ($strOperation =="IN" && (is_array($val) && array_sum($val) > 0 || strlen($val) > 0))
					{
						$val = (!is_array($val) ? explode(",", $val) : $val);
						$val_int = array();
						foreach ($val as $k => $v):
//.........这里部分代码省略.........
开发者ID:ASDAFF,项目名称:entask.ru,代码行数:101,代码来源:message.php

示例3: GetListEx

 function GetListEx($arOrder = array("SORT" => "ASC"), $arFilter = array(), $bCount = false, $iNum = 0, $arAddParams = array())
 {
     global $DB, $USER;
     $arOrder = is_array($arOrder) ? $arOrder : array();
     $arFilter = is_array($arFilter) ? $arFilter : array();
     $arSqlSearch = array();
     $arSqlFrom = array();
     $arSqlSelect = array();
     $arSqlGroup = array();
     $arSqlOrder = array();
     $strSqlSearch = "";
     $strSqlFrom = "";
     $strSqlSelect = "";
     $strSqlGroup = "";
     $strSqlOrder = "";
     $UseGroup = false;
     $arAddParams = is_array($arAddParams) ? $arAddParams : array($arAddParams);
     foreach ($arFilter as $key => $val) {
         $key_res = CForumNew::GetFilterOperation($key);
         $key = strtoupper($key_res["FIELD"]);
         $strNegative = $key_res["NEGATIVE"];
         $strOperation = $key_res["OPERATION"];
         switch ($key) {
             case "STATE":
             case "XML_ID":
             case "APPROVED":
                 if (strlen($val) <= 0) {
                     $arSqlSearch[] = ($strNegative == "Y" ? "NOT" : "") . "(FT." . $key . " IS NULL OR " . ($DB->type == "MSSQL" ? "LEN" : "LENGTH") . "(FT." . $key . ")<=0)";
                 } else {
                     $arSqlSearch[] = ($strNegative == "Y" ? " FT." . $key . " IS NULL OR NOT " : "") . "(FT." . $key . " " . $strOperation . " '" . $DB->ForSql($val) . "' )";
                 }
                 break;
             case "ID":
             case "FORUM_ID":
             case "SOCNET_GROUP_ID":
             case "OWNER_ID":
             case "USER_START_ID":
             case "SORT":
             case "POSTS":
             case "TOPICS":
                 if ($strOperation != "IN" && intVal($val) > 0) {
                     $arSqlSearch[] = ($strNegative == "Y" ? " FT." . $key . " IS NULL OR NOT " : "") . "(FT." . $key . " " . $strOperation . " " . intVal($val) . " )";
                 } elseif ($strOperation == "IN" && (is_array($val) && array_sum($val) > 0 || strlen($val) > 0)) {
                     if (!is_array($val)) {
                         $val = explode(',', $val);
                     }
                     $val_int = array();
                     foreach ($val as $v) {
                         $val_int[] = intVal($v);
                     }
                     $val = implode(", ", $val_int);
                     $arSqlSearch[] = ($strNegative == "Y" ? " NOT " : "") . "(FT." . $key . " IN (" . $DB->ForSql($val) . ") )";
                 } else {
                     $arSqlSearch[] = ($strNegative == "Y" ? "NOT" : "") . "(FT." . $key . " IS NULL OR FT." . $key . "<=0)";
                 }
                 break;
             case "TITLE_ALL":
                 $arSqlSearch[] = GetFilterQuery("FT.TITLE, FT.DESCRIPTION", $val);
                 break;
             case "TITLE":
             case "DESCRIPTION":
                 $arSqlSearch[] = GetFilterQuery("FT." . $key, $val);
                 $arSqlSearch[] = GetFilterQuery("FT." . $key, $val);
                 break;
             case "START_DATE":
             case "LAST_POST_DATE":
             case "ABS_LAST_POST_DATE":
                 if (strlen($val) <= 0) {
                     $arSqlSearch[] = ($strNegative == "Y" ? "NOT" : "") . "(FT." . $key . " IS NULL)";
                 } else {
                     $arSqlSearch[] = ($strNegative == "Y" ? " FT." . $key . " IS NULL OR NOT " : "") . "(FT." . $key . " " . $strOperation . " " . $DB->CharToDateFunction($DB->ForSql($val), "FULL") . ")";
                 }
                 break;
             case "USER_ID":
                 $arSqlSelect["LAST_VISIT"] = $DB->DateToCharFunction("FUT.LAST_VISIT", "FULL");
                 $arSqlFrom["FUT"] = "LEFT JOIN b_forum_user_topic FUT ON (" . (strlen($val) <= 0 ? ($strNegative == "Y" ? "NOT" : "") . "(FUT.USER_ID IS NULL)" : "FUT.USER_ID=" . intVal($val)) . " AND FUT.FORUM_ID = FT.FORUM_ID AND FUT.TOPIC_ID = FT.ID)";
                 break;
             case "RENEW_TOPIC":
                 if (strlen($val) > 0 && array_key_exists("FUT", $arSqlFrom)) {
                     $arSqlSearch[] = "((FT.LAST_POST_DATE " . $strOperation . " " . $DB->CharToDateFunction($DB->ForSql($val), "FULL") . ") AND\n\t\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t\t(LAST_VISIT IS NULL) OR\n\t\t\t\t\t\t\t\t\t\t(LAST_VISIT < " . $DB->CharToDateFunction($DB->ForSql($val), "FULL") . ")\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\tOR\n\t\t\t\t\t\t\t\t((FT.LAST_POST_DATE > FUT.LAST_VISIT) AND \n\t\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t\t(LAST_VISIT IS NOT NULL) AND\n\t\t\t\t\t\t\t\t\t\t(LAST_VISIT > " . $DB->CharToDateFunction($DB->ForSql($val), "FULL") . ")\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t)";
                 }
                 break;
             case "PERMISSION":
                 if (!is_array($val)) {
                     $val = explode(',', $val);
                 }
                 if (empty($val)) {
                     $val = $GLOBALS["USER"]->GetGroups();
                 } elseif (is_array($val)) {
                     $val_int = array();
                     foreach ($val as $v) {
                         $val_int[] = intVal($v);
                     }
                     $val = implode(", ", $val_int);
                 }
                 $arSqlFrom["FPP"] = " INNER JOIN ( \n" . "\tSELECT FPP.FORUM_ID, MAX(FPP.PERMISSION) AS PERMISSION \n" . "\tFROM b_forum_perms FPP \n" . "\tWHERE FPP.GROUP_ID IN (" . $DB->ForSql($val) . ") AND FPP.PERMISSION > 'A' \n" . "\tGROUP BY FPP.FORUM_ID) FPP ON (FPP.FORUM_ID = FT.FORUM_ID) ";
                 $arSqlSelect[] = "FPP.PERMISSION AS PERMISSION";
                 break;
             case "RENEW":
                 $val = is_array($val) ? $val : array("USER_ID" => $val);
//.........这里部分代码省略.........
开发者ID:supertest223,项目名称:bitrixtest,代码行数:101,代码来源:topic.php

示例4: GetListEx

 function GetListEx($arOrder = array("SORT" => "ASC"), $arFilter = array())
 {
     global $DB;
     $arSqlSearch = array();
     $strSqlSearch = "";
     $arSqlOrder = array();
     $strSqlOrder = "";
     $arFilter = is_array($arFilter) ? $arFilter : array();
     foreach ($arFilter as $key => $val) {
         $key_res = CForumNew::GetFilterOperation($key);
         $key = strtoupper($key_res["FIELD"]);
         $strNegative = $key_res["NEGATIVE"];
         $strOperation = $key_res["OPERATION"];
         switch ($key) {
             case "ID":
             case "SORT":
             case "PARENT_ID":
             case "LEFT_MARGIN":
             case "RIGHT_MARGIN":
             case "DEPTH_LEVEL":
                 if (intVal($val) <= 0) {
                     $arSqlSearch[] = ($strNegative == "Y" ? "NOT" : "") . "(FR." . $key . " IS NULL OR FR." . $key . "<=0)";
                 } else {
                     $arSqlSearch[] = ($strNegative == "Y" ? " FR." . $key . " IS NULL OR NOT " : "") . "(FR." . $key . " " . $strOperation . " " . intVal($val) . " )";
                 }
                 break;
             case "LID":
                 if (strlen($val) <= 0) {
                     $arSqlSearch[] = ($strNegative == "Y" ? "NOT" : "") . "(FRL.LID IS NULL OR " . ($DB->type == "MSSQL" ? "LEN" : "LENGTH") . "(FRL.LID)<=0)";
                 } else {
                     $arSqlSearch[] = ($strNegative == "Y" ? " FRL.LID IS NULL OR NOT " : "") . "(FRL.LID " . $strOperation . " '" . $DB->ForSql($val) . "' )";
                 }
                 break;
         }
     }
     if (!empty($arSqlSearch)) {
         $strSqlSearch = " WHERE (" . implode(") AND (", $arSqlSearch) . ") ";
     }
     foreach ($arOrder as $by => $order) {
         $by = strtoupper($by);
         $order = strtoupper($order);
         if ($order != "ASC") {
             $order = "DESC";
         }
         if ($by == "ID") {
             $arSqlOrder[] = " FR.ID " . $order . " ";
         } elseif ($by == "LID") {
             $arSqlOrder[] = " FRL.LID " . $order . " ";
         } elseif ($by == "NAME") {
             $arSqlOrder[] = " FRL.NAME " . $order . " ";
         } elseif ($by == "LEFT_MARGIN") {
             $arSqlOrder[] = " FR.LEFT_MARGIN " . $order . " ";
         } else {
             $arSqlOrder[] = " FR.SORT " . $order . " ";
             $by = "SORT";
         }
     }
     DelDuplicateSort($arSqlOrder);
     if (!empty($arSqlOrder)) {
         $strSqlOrder = "ORDER BY " . implode(", ", $arSqlOrder);
     }
     $strSql = "SELECT FR.ID, FR.SORT, FR.PARENT_ID, FR.LEFT_MARGIN, FR.RIGHT_MARGIN, FR.DEPTH_LEVEL, FRL.LID, FRL.NAME, FRL.DESCRIPTION " . "FROM b_forum_group FR " . "\tLEFT JOIN b_forum_group_lang FRL ON FR.ID = FRL.FORUM_GROUP_ID " . $strSqlSearch . " " . $strSqlOrder . " ";
     $db_res = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     return $db_res;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:65,代码来源:forum_new.php

示例5: GetList

	/**
	 * <p>Возвращает голосования за посетителей форума, которые удовлетворяют фильтру arFilter, упорядоченные в соответствии с порядком arOrder.</p>
	 *
	 *
	 *
	 *
	 * @param array $arrayarOrder = array("TO_USER_ID"=>"ASC") <p>Порядок сортировки записей; представляет собой ассоциативный
	 * массив, в котором ключами являются названия параметров
	 * голосования, а значениями - направления сортировки.</p>
	 * <p>Допустимые параметры голосования для сортировки: <br> FROM_USER_ID -
	 * код голосовавшего посетителя <br> TO_USER_ID - код посетителя, за
	 * которого голосовали <br> POINTS - количество отданных голосов <br>
	 * DATE_UPDATE - дата последнего изменения записи </p>
	 *
	 *
	 *
	 * @param array $arrayarFilter = array() <p>Фильтр на возвращаемые голосования; представляет собой
	 * ассоциативный массив, в котором ключами являются названия
	 * параметров голосования, а значениями - условия на эти
	 * параметры.</p> <p>Допустимые параметры голосования для фильтрации:
	 * <br> FROM_USER_ID - код голосовавшего посетителя <br> TO_USER_ID - код
	 * посетителя, за которого голосовали</p>
	 *
	 *
	 *
	 * @return CDBResult <p>Возвращяется объект класса CDBResult, каждая запись которого
	 * представляет собой массив с ключами.</p><table class="tnormal" width="100%"><tbody> <tr>
	 * <th width="15%">Ключ</th> <th>Значение</th> </tr> <tr> <td>FROM_USER_ID</td> <td>Код
	 * пользователя, который отдал голос.</td> </tr> <tr> <td>TO_USER_ID</td> <td>Код
	 * пользователя, за которого отдали голос.</td> </tr> <tr> <td>POINTS</td>
	 * <td>Количество отданных голосов.</td> </tr> <tr> <td>DATE_UPDATE</td> <td>Дата
	 * последнего изменения записи.</td> </tr> </tbody></table>
	 *
	 * @static
	 * @link http://dev.1c-bitrix.ru/api_help/forum/developer/cforumuserpoints/cforumuserpoints__getlist.b43c7704.php
	 * @author Bitrix
	 */
	public static function GetList($arOrder = array("TO_USER_ID"=>"ASC"), $arFilter = array())
	{
		global $DB;
		$arSqlSearch = Array();
		$strSqlSearch = "";
		$arSqlOrder = Array();
		$strSqlOrder = "";
		$arFilter = (is_array($arFilter) ? $arFilter : array());

		foreach ($arFilter as $key => $val)
		{
			$key_res = CForumNew::GetFilterOperation($key);
			$key = strtoupper($key_res["FIELD"]);
			$strNegative = $key_res["NEGATIVE"];
			$strOperation = $key_res["OPERATION"];

			switch ($key)
			{
				case "FROM_USER_ID":
				case "TO_USER_ID":
					if (IntVal($val)<=0)
						$arSqlSearch[] = ($strNegative=="Y"?"NOT":"")."(FR.".$key." IS NULL OR FR.".$key."<=0)";
					else
						$arSqlSearch[] = ($strNegative=="Y"?" FR.".$key." IS NULL OR NOT ":"")."(FR.".$key." ".$strOperation." ".IntVal($val)." )";
					break;
			}
		}
		if (!empty($arSqlSearch))
			$strSqlSearch = " WHERE (".implode(") AND (", $arSqlSearch).") ";

		foreach ($arOrder as $by=>$order)
		{
			$by = strtoupper($by); $order = strtoupper($order);
			if ($order!="ASC") $order = "DESC";

			if ($by == "FROM_USER_ID") $arSqlOrder[] = " FR.FROM_USER_ID ".$order." ";
			elseif ($by == "POINTS") $arSqlOrder[] = " FR.POINTS ".$order." ";
			elseif ($by == "DATE_UPDATE") $arSqlOrder[] = " FR.DATE_UPDATE ".$order." ";
			else
			{
				$arSqlOrder[] = " FR.TO_USER_ID ".$order." ";
				$by = "TO_USER_ID";
			}
		}
		DelDuplicateSort($arSqlOrder);
		if (!empty($arSqlOrder))
			$strSqlOrder = " ORDER BY ".implode(", ", $arSqlOrder);

		$strSql =
			"SELECT FR.FROM_USER_ID, FR.TO_USER_ID, FR.POINTS, FR.DATE_UPDATE ".
			"FROM b_forum_user_points FR ".
			$strSqlSearch." ".
			$strSqlOrder;
		$db_res = $DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);
		return $db_res;
	}
开发者ID:ASDAFF,项目名称:bxApiDocs,代码行数:93,代码来源:points.php

示例6: GetListEx

	function GetListEx($arOrder = array("SORT"=>"ASC"), $arFilter = array())
	{
		global $DB;
		$arSqlSearch = Array();
		$strSqlSearch = "";
		$arSqlOrder = Array();
		$strSqlOrder = "";
		$arFilter = (is_array($arFilter) ? $arFilter : array());

		foreach ($arFilter as $key => $val)
		{
			$key_res = CForumNew::GetFilterOperation($key);
			$key = strtoupper($key_res["FIELD"]);
			$strNegative = $key_res["NEGATIVE"];
			$strOperation = $key_res["OPERATION"];

			switch ($key)
			{
				case "ID":
				case "SORT":
					if (intVal($val)<=0)
						$arSqlSearch[] = ($strNegative=="Y"?"NOT":"")."(FR.".$key." IS NULL OR FR.".$key."<=0)";
					else
						$arSqlSearch[] = ($strNegative=="Y"?" FR.".$key." IS NULL OR NOT ":"")."(FR.".$key." ".$strOperation." ".intVal($val)." )";
					break;
				case "TYPE":
					if (strlen($val)<=0)
						$arSqlSearch[] = ($strNegative=="Y"?"NOT":"")."(FR.TYPE IS NULL OR ".($DB->type == "MSSQL" ? "LEN" : "LENGTH")."(FR.TYPE)<=0)";
					else
						$arSqlSearch[] = ($strNegative=="Y"?" FR.TYPE IS NULL OR NOT ":"")."(FR.TYPE ".$strOperation." '".$DB->ForSql($val)."' )";
					break;
				case "LID":
					if (strlen($val)<=0)
						$arSqlSearch[] = ($strNegative=="Y"?"NOT":"")."(FRL.LID IS NULL OR ".($DB->type == "MSSQL" ? "LEN" : "LENGTH")."(FRL.LID)<=0)";
					else
						$arSqlSearch[] = ($strNegative=="Y"?" FRL.LID IS NULL OR NOT ":"")."(FRL.LID ".$strOperation." '".$DB->ForSql($val)."' )";
					break;
			}
		}
		if (!empty($arSqlSearch))
			$strSqlSearch = " WHERE (".implode(") AND (", $arSqlSearch).") ";

		foreach ($arOrder as $by=>$order)
		{
			$by = strtoupper($by); $order = strtoupper($order);
			$order = ($order == "ASC" ? "ASC" : "DESC");

			if ($by == "ID") $arSqlOrder[] = " FR.ID ".$order." ";
			elseif ($by == "LID") $arSqlOrder[] = " FRL.LID ".$order." ";
			elseif ($by == "NAME") $arSqlOrder[] = " FRL.NAME ".$order." ";
			elseif ($by == "TYPE") $arSqlOrder[] = " FR.TYPE ".$order." ";
			else
			{
				$arSqlOrder[] = " FR.SORT ".$order." ";
				$by = "SORT";
			}
		}
		DelDuplicateSort($arSqlOrder);
		if (!empty($arSqlOrder))
			$strSqlOrder = " ORDER BY ".implode(", ", $arSqlOrder);

		$strSql =
			"SELECT FR.ID, FR.SORT, FR.TYPE, FR.TYPING, FR.IMAGE, FR.CLICKABLE, ".
			"	FRL.LID, FRL.NAME, FR.DESCRIPTION, FR.IMAGE_WIDTH, FR.IMAGE_HEIGHT ".
			"FROM b_forum_smile FR ".
			"	LEFT JOIN b_forum_smile_lang FRL ON FR.ID = FRL.SMILE_ID ".
			$strSqlSearch." ".
			$strSqlOrder;
		$db_res = $DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);
		return $db_res;
	}
开发者ID:ASDAFF,项目名称:entask.ru,代码行数:71,代码来源:forum_new.php

示例7: GetListEx

 public static function GetListEx($arOrder = array("ID" => "ASC"), $arFilter = array(), $bCount = false, $iNum = 0, $arAddParams = array())
 {
     global $DB;
     $arSqlSearch = array();
     $arSqlOrder = array();
     $strSqlSearch = "";
     $strSqlOrder = "";
     $strSqlFrom = "";
     $arFilter = is_array($arFilter) ? $arFilter : array();
     if (is_array($bCount) && empty($arAddParams)) {
         $arAddParams = $bCount;
         $bCount = false;
         $iNum = 0;
     }
     $arAddParams = is_array($arAddParams) ? $arAddParams : array($arAddParams);
     if (is_set($arAddParams, "nameTemplate")) {
         $arAddParams["sNameTemplate"] = $arAddParams["nameTemplate"];
     }
     $arAddParams["bCount"] = !!$bCount || !!$arAddParams["bCount"];
     $arAddParams["nTopCount"] = $iNum > 0 ? $iNum : ($arAddParams["nTopCount"] > 0 ? $arAddParams["nTopCount"] : 0);
     foreach ($arFilter as $key => $val) {
         $key_res = CForumNew::GetFilterOperation($key);
         $key = strtoupper($key_res["FIELD"]);
         $strNegative = $key_res["NEGATIVE"];
         $strOperation = $key_res["OPERATION"];
         switch ($key) {
             case "ID":
             case "FOLDER_ID":
             case "AUTHOR_ID":
             case "RECIPIENT_ID":
             case "USER_ID":
                 if (IntVal($val) <= 0) {
                     $arSqlSearch[] = ($strNegative == "Y" ? "NOT" : "") . "(PM." . $key . " IS NULL OR PM." . $key . "<=0)";
                 } elseif (strToUpper($strOperation) == "IN") {
                     $arSqlSearch[] = ($strNegative == "Y" ? " PM." . $key . " IS NULL OR NOT " : "") . "(PM." . $key . " " . $strOperation . " (" . IntVal($val) . ") )";
                 } else {
                     $arSqlSearch[] = ($strNegative == "Y" ? " PM." . $key . " IS NULL OR NOT " : "") . "(PM." . $key . " " . $strOperation . " " . IntVal($val) . " )";
                 }
                 break;
             case "OWNER_ID":
                 if (COption::GetOptionString("forum", "UsePMVersion", "2") == 2) {
                     $user_id = 0;
                     if (is_array($val) && intVal($val["USER_ID"]) > 0) {
                         $user_id = intVal($val["USER_ID"]);
                     } else {
                         $user_id = intVal($val);
                     }
                     $arSqlSearch[] = "(PM.USER_ID=" . $user_id . " AND ((PM.FOLDER_ID=2) OR (PM.FOLDER_ID=3)))";
                 } else {
                     $arSqlSearch[] = "((PM.AUTHOR_ID=" . intVal($val) . ") AND (PM.IS_READ='N')) OR (PM.USER_ID=" . intVal($val) . " AND (PM.FOLDER_ID=2))";
                 }
                 break;
             case "POST_SUBJ":
             case "POST_MESSAGE":
             case "USE_SMILES":
             case "IS_READ":
                 if (strlen($val) <= 0) {
                     $arSqlSearch[] = ($strNegative == "Y" ? "NOT" : "") . "(PM." . $key . " IS NULL OR LENGTH(PM." . $key . ")<=0)";
                 } elseif (strToUpper($strOperation) == "IN") {
                     $arSqlSearch[] = ($strNegative == "Y" ? " PM." . $key . " IS NULL OR NOT " : "") . "(PM." . $key . " " . $strOperation . " ('" . $DB->ForSql($val) . "') )";
                 } else {
                     $arSqlSearch[] = ($strNegative == "Y" ? " PM." . $key . " IS NULL OR NOT " : "") . "(PM." . $key . " " . $strOperation . " '" . $DB->ForSql($val) . "' )";
                 }
                 break;
             case "POST_DATE":
                 if (strlen($val) <= 0) {
                     $arSqlSearch[] = ($strNegative == "Y" ? "NOT" : "") . "(PM." . $key . " IS NULL OR LENGTH(PM." . $key . ")<=0)";
                 } else {
                     $arSqlSearch[] = ($strNegative == "Y" ? " PM." . $key . " IS NULL OR NOT " : "") . "(PM." . $key . " " . $strOperation . " " . $DB->CharToDateFunction($DB->ForSql($val), "FULL") . " )";
                 }
                 break;
         }
     }
     if (!empty($arSqlSearch)) {
         $strSqlSearch = " AND (" . implode(") AND (", $arSqlSearch) . ") ";
     }
     $iCnt = 0;
     if ($arAddParams["bCount"] || is_set($arAddParams, "bDescPageNumbering")) {
         $strSql = "SELECT COUNT(PM.ID) AS CNT FROM b_forum_private_message PM WHERE (1=1) " . $strSqlSearch;
         $db_res = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         $iCnt = $db_res && ($res = $db_res->Fetch()) ? intval($res["CNT"]) : 0;
         if ($arAddParams["bCount"]) {
             return $iCnt;
         }
     }
     foreach ($arOrder as $by => $order) {
         $by = strtoupper($by);
         $order = strtoupper($order);
         if ($order != "ASC") {
             $order = "DESC";
         }
         if ($by == "AUTHOR_NAME") {
             $arSqlOrder[] = " AUTHOR_NAME " . $order . " ";
         } elseif ($by == "RECIPIENT_NAME") {
             $arSqlOrder[] = " RECIPIENT_NAME " . $order . " ";
         } elseif ($by == "AUTHOR_ID") {
             $arSqlOrder[] = " PM.AUTHOR_ID " . $order . " ";
         } elseif ($by == "RECIPIENT_ID") {
             $arSqlOrder[] = " PM.RECIPIENT_ID " . $order . " ";
         } elseif ($by == "POST_DATE") {
//.........这里部分代码省略.........
开发者ID:rasuldev,项目名称:torino,代码行数:101,代码来源:private_message.php


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