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


PHP CVote::GetFilterOperation方法代码示例

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


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

示例1: GetListEx

 function GetListEx($arOrder = array(), $arFilter = array())
 {
     global $DB;
     $arSqlSearch = array();
     $arOrder = is_array($arOrder) ? $arOrder : array();
     $arFilter = is_array($arFilter) ? $arFilter : array();
     foreach ($arFilter as $key => $val) {
         $key_res = CVote::GetFilterOperation($key);
         $key = strtoupper($key_res["FIELD"]);
         $strNegative = $key_res["NEGATIVE"];
         $strOperation = $key_res["OPERATION"];
         switch ($key) {
             case "CHANNEL_ID":
             case "COUNTER":
             case "ID":
                 $str = ($strNegative == "Y" ? "NOT" : "") . "(V." . $key . " IS NULL OR V." . $key . "<=0)";
                 if (!empty($val)) {
                     $str = ($strNegative == "Y" ? " V." . $key . " IS NULL OR NOT " : "") . "(V." . $key . " " . $strOperation . " " . intVal($val) . ")";
                     if ($strOperation == "IN") {
                         $val = array_unique(array_map("intval", is_array($val) ? $val : explode(",", $val)), SORT_NUMERIC);
                         if (!empty($val)) {
                             $str = ($strNegative == "Y" ? " NOT " : "") . "(V." . $key . " IN (" . implode(",", $val) . "))";
                         }
                     }
                 }
                 $arSqlSearch[] = $str;
                 break;
             case "ACTIVE":
                 if (empty($val)) {
                     $arSqlSearch[] = ($strNegative == "Y" ? "NOT" : "") . "(V." . $key . " IS NULL OR LENGTH(V." . $key . ")<=0)";
                 } else {
                     $arSqlSearch[] = ($strNegative == "Y" ? " V." . $key . " IS NULL OR NOT " : "") . "(V." . $key . " " . $strOperation . " '" . $DB->ForSql($val) . "' )";
                 }
                 break;
             case "DATE_START":
             case "DATE_END":
                 if (empty($val)) {
                     $arSqlSearch[] = ($strNegative == "Y" ? "NOT" : "") . "(V." . $key . " IS NULL OR LENGTH(V." . $key . ")<=0)";
                 } else {
                     $arSqlSearch[] = ($strNegative == "Y" ? " V." . $key . " IS NULL OR NOT " : "") . "(V." . $key . " " . $strOperation . " " . $DB->CharToDateFunction($DB->ForSql($val), "FULL") . " )";
                 }
                 break;
         }
     }
     $strSqlSearch = !empty($arSqlSearch) ? " AND (" . implode(") AND (", $arSqlSearch) . ") " : "";
     $arSqlOrder = array();
     foreach ($arOrder as $by => $order) {
         $by = strtoupper($by);
         $by = in_array($by, array("ID", "TITLE", "DATE_START", "DATE_END", "COUNTER", "ACTIVE", "C_SORT", "CHANNEL_ID")) ? $by : "ID";
         $arSqlOrder[] = "V." . $by . " " . (strtoupper($order) == "ASC" ? "ASC" : "DESC");
     }
     DelDuplicateSort($arSqlOrder);
     $strSqlOrder = !empty($arSqlOrder) ? "ORDER BY " . implode(",", $arSqlOrder) : "";
     $strSql = "\n\t\t\tSELECT V.*,\n\t\t\t\tC.TITLE as CHANNEL_TITLE,\n\t\t\t\tC.SYMBOLIC_NAME as CHANNEL_SYMBOLIC_NAME,\n\t\t\t\tC.C_SORT as CHANNEL_C_SORT,\n\t\t\t\tC.FIRST_SITE_ID as CHANNEL_FIRST_SITE_ID,\n\t\t\t\tC.ACTIVE as CHANNEL_ACTIVE,\n\t\t\t\tC.HIDDEN as CHANNEL_HIDDEN,\n\t\t\t\tC.TITLE as CHANNEL_TITLE,\n\t\t\t\tC.VOTE_SINGLE as CHANNEL_VOTE_SINGLE,\n\t\t\t\tC.USE_CAPTCHA as CHANNEL_USE_CAPTCHA,\n\t\t\t\t" . $DB->DateToCharFunction("V.TIMESTAMP_X") . " TIMESTAMP_X,\n\t\t\t\t" . $DB->DateToCharFunction("V.DATE_START") . " DATE_START,\n\t\t\t\t" . $DB->DateToCharFunction("V.DATE_END") . " DATE_END,\n\t\t\t\tCASE WHEN (C.ACTIVE = 'Y' AND V.ACTIVE = 'Y' AND V.DATE_START <= NOW() AND NOW() <= V.DATE_END)\n\t\t\t\t\tTHEN IF (C.VOTE_SINGLE != 'Y', 'green', 'yellow')\n\t\t\t\t\tELSE 'red'\n\t\t\t\tEND AS LAMP\n\t\t\tFROM b_vote V\n\t\t\tINNER JOIN b_vote_channel C ON (V.CHANNEL_ID = C.ID)\n\t\t\tWHERE 1=1 " . $strSqlSearch . " " . $strSqlOrder;
     return new _CVoteDBResult($DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__));
 }
开发者ID:Satariall,项目名称:izurit,代码行数:56,代码来源:vote.php


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