本文整理汇总了PHP中CForumTopic::GetSelectFields方法的典型用法代码示例。如果您正苦于以下问题:PHP CForumTopic::GetSelectFields方法的具体用法?PHP CForumTopic::GetSelectFields怎么用?PHP CForumTopic::GetSelectFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CForumTopic
的用法示例。
在下文中一共展示了CForumTopic::GetSelectFields方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: GetByIDEx
function GetByIDEx($ID, $arAddParams = array())
{
global $DB;
$ID = intVal($ID);
$res = false;
if ($ID <= 0) {
return false;
}
$arAddParams = is_array($arAddParams) ? $arAddParams : array($arAddParams);
$arAddParams["GET_TOPIC_INFO"] = $arAddParams["GET_TOPIC_INFO"] == "Y" ? "Y" : "N";
$arAddParams["FILTER_TOPIC_INFO"] = $arAddParams["FILTER_TOPIC_INFO"] == "N" ? "N" : "Y";
$arAddParams["GET_FORUM_INFO"] = $arAddParams["GET_FORUM_INFO"] == "Y" ? "Y" : "N";
$arAddParams["FILTER_FORUM_INFO"] = $arAddParams["FILTER_FORUM_INFO"] == "N" ? "N" : "Y";
$arAddParams["FILTER_MESSAGE_INFO"] = $arAddParams["FILTER_MESSAGE_INFO"] == "N" ? "N" : "Y";
if (COption::GetOptionString("forum", "FILTER", "Y") == "Y") {
$arAddParams["FILTER"] = is_set($arAddParams, "FILTER") ? $arAddParams["FILTER"] : "P";
$arAddParams["FILTER"] = $arAddParams["FILTER"] == "Y" || $arAddParams["FILTER"] == "P" ? $arAddParams["FILTER"] : "N";
} else {
$arAddParams["FILTER"] = "N";
}
if ($arAddParams["FILTER"] == "N") {
$arAddParams["FILTER_TOPIC_INFO"] = "N";
$arAddParams["FILTER_FORUM_INFO"] = "N";
$arAddParams["FILTER_MESSAGE_INFO"] = "N";
} elseif ($arAddParams["FILTER"] == "P") {
$arAddParams["FILTER_MESSAGE_INFO"] = "N";
}
$arSqlSelect = array();
$arSqlFrom = array();
if ($arAddParams["GET_TOPIC_INFO"] == "Y") {
$arSqlSelect[] = CForumTopic::GetSelectFields(array("sPrefix" => "FT_", "sReturnResult" => "string"));
if ($arAddParams["FILTER_TOPIC_INFO"] != "N") {
$arSqlSelect[] = "FT.HTML as FT_HTML";
}
$arSqlSelect[] = "FT.XML_ID as FT_XML_ID";
$arSqlFrom[] = "INNER JOIN b_forum_topic FT ON (FM.TOPIC_ID = FT.ID)";
}
if ($arAddParams["GET_FORUM_INFO"] == "Y") {
$arSqlSelect[] = CForumNew::GetSelectFields(array("sPrefix" => "F_", "sReturnResult" => "string"));
if ($arAddParams["FILTER_FORUM_INFO"] != "N") {
$arSqlSelect[] = "F.HTML as F_HTML";
}
$arSqlFrom[] = "INNER JOIN b_forum F ON (FM.FORUM_ID = F.ID)";
}
$strSql = "SELECT FM.*, " . $DB->DateToCharFunction("FM.POST_DATE", "FULL") . " as POST_DATE,\n\t\t\t\tFU.SHOW_NAME, FU.DESCRIPTION, FU.NUM_POSTS, FU.POINTS as NUM_POINTS, FU.SIGNATURE, FU.AVATAR, FU.RANK_ID,\n\t\t\t\t" . $DB->DateToCharFunction("FU.DATE_REG", "SHORT") . " as DATE_REG,\n\t\t\t\tU.EMAIL, U.PERSONAL_ICQ, U.LOGIN, U.NAME, U.SECOND_NAME, U.LAST_NAME" . (!empty($arSqlSelect) ? ", " . implode(", ", $arSqlSelect) : "") . "\n\t\t\tFROM b_forum_message FM\n\t\t\t\tLEFT JOIN b_forum_user FU ON (FM.AUTHOR_ID = FU.USER_ID)\n\t\t\t\tLEFT JOIN b_user U ON (FM.AUTHOR_ID = U.ID)\n\t\t\t\t" . implode(" ", $arSqlFrom) . "\n\t\t\tWHERE FM.ID = " . $ID . "";
$db_res = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
if ($db_res && ($res = $db_res->Fetch())) {
if ($arAddParams["FILTER_MESSAGE_INFO"] == "N") {
unset($res["HTML"]);
}
if ($arAddParams["GET_TOPIC_INFO"] == "Y" && COption::GetOptionString("forum", "FILTER", "Y") == "Y") {
$arTopic = array();
foreach ($res as $key => $val) {
if (substr($key, 0, 3) == "FT_") {
$arTopic[substr($key, 3)] = $val;
}
}
if (!empty($arTopic)) {
$GLOBALS["FORUM_CACHE"]["TOPIC"][intVal($res["TOPIC_INFO"]["ID"])] = $arTopic;
$db_res_filter = new CDBResult();
$db_res_filter->InitFromArray(array($arTopic));
$db_res_filter = new _CTopicDBResult($db_res_filter);
if ($res_filter = $db_res_filter->Fetch()) {
$GLOBALS["FORUM_CACHE"]["TOPIC_FILTER"][intVal($res["TOPIC_INFO"]["ID"])] = $res_filter;
}
}
}
$db_res = new CDBResult();
$db_res->InitFromArray(array($res));
$db_res = new _CMessageDBResult($db_res, $arAddParams);
$res = $db_res->Fetch();
if ($arAddParams["GET_TOPIC_INFO"] == "Y" || $arAddParams["GET_FORUM_INFO"] == "Y") {
$res["TOPIC_INFO"] = array();
$res["FORUM_INFO"] = array();
$res["MESSAGE_INFO"] = array();
foreach ($res as $key => $val) {
if (substr($key, 0, 3) == "FT_") {
$res["TOPIC_INFO"][substr($key, 3)] = $val;
} elseif (substr($key, 0, 2) == "F_") {
$res["FORUM_INFO"][substr($key, 2)] = $val;
} else {
$res["MESSAGE_INFO"][$key] = $val;
}
}
if (COption::GetOptionString("forum", "FILTER", "Y") != "Y" && !empty($res["TOPIC_INFO"])) {
$GLOBALS["FORUM_CACHE"]["TOPIC"][intVal($res["TOPIC_INFO"]["ID"])] = $res["TOPIC_INFO"];
}
if (!empty($res["FORUM_INFO"])) {
$GLOBALS["FORUM_CACHE"]["FORUM"][intVal($res["FORUM_INFO"]["ID"])] = $res["FORUM_INFO"];
}
}
if ($arAddParams["getFiles"] == "Y" && !empty($res)) {
$res["FILES"] = CForumFiles::getByMessageID($ID);
}
return $res;
}
return false;
}