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


PHP CForumNew::prepareField方法代码示例

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


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

示例1: 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":
                 $val = CForumNew::prepareField($strOperation, "string", $val);
                 if ($val == '') {
                     $arSqlSearch[] = ($strNegative == "Y" ? "NOT" : "") . "(FT." . $key . " IS NULL OR " . ($DB->type == "MSSQL" ? "LEN" : "LENGTH") . "(FT." . $key . ")<=0)";
                 } else {
                     if ($strOperation == "IN") {
                         $arSqlSearch[] = ($strNegative == "Y" ? " NOT " : "") . "(FT." . $key . " IN (" . $val . ") )";
                     } else {
                         $arSqlSearch[] = ($strNegative == "Y" ? " FT." . $key . " IS NULL OR NOT " : "") . "(FT." . $key . " " . $strOperation . " '" . $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 || is_string($val) && 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);
                 }
//.........这里部分代码省略.........
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:101,代码来源:topic.php


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