本文整理汇总了PHP中CDatabase::GetModuleConnection方法的典型用法代码示例。如果您正苦于以下问题:PHP CDatabase::GetModuleConnection方法的具体用法?PHP CDatabase::GetModuleConnection怎么用?PHP CDatabase::GetModuleConnection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CDatabase
的用法示例。
在下文中一共展示了CDatabase::GetModuleConnection方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: GetLastByID
public static function GetLastByID($ID)
{
$DB = CDatabase::GetModuleConnection('statistic');
$ID = intval($ID);
if($ID>0)
{
$strSql = "
SELECT
G.ID,
G.FAVORITES,
G.LAST_USER_ID,
A.ID as LAST_ADV_ID,
if(to_days(curdate())=to_days(G.LAST_DATE), 'Y', 'N') LAST
FROM b_stat_guest G
LEFT JOIN b_stat_adv A ON A.ID = G.LAST_ADV_ID
WHERE G.ID='$ID'
";
$res = $DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);
}
else
{
$res = new CDBResult;
$res->InitFromArray(array());
}
return $res;
}
示例2: DelayedStemIndex
function DelayedStemIndex()
{
$DB = CDatabase::GetModuleConnection('search');
$etime = time() + intval(COption::GetOptionString("search", "agent_duration"));
do {
$stemQueue = $DB->Query($DB->TopSql("\n\t\t\t\tSELECT SEARCH_CONTENT_ID ID\n\t\t\t\tFROM b_search_content_stem\n\t\t\t\tWHERE SEARCH_CONTENT_ID < 0\n\t\t\t", 1));
if ($stemTask = $stemQueue->Fetch()) {
$ID = -$stemTask["ID"];
$sites = array();
$rsSite = $DB->Query("\n\t\t\t\t\tSELECT SITE_ID, URL\n\t\t\t\t\tFROM b_search_content_site\n\t\t\t\t\tWHERE SEARCH_CONTENT_ID = " . $ID . "\n\t\t\t\t");
while ($arSite = $rsSite->Fetch()) {
$sites[$arSite["SITE_ID"]] = $arSite["URL"];
}
if (BX_SEARCH_VERSION > 1) {
$sql = "SELECT SEARCHABLE_CONTENT from b_search_content_text WHERE SEARCH_CONTENT_ID = {$ID}";
} else {
$sql = "SELECT SEARCHABLE_CONTENT from b_search_content WHERE ID = {$ID}";
}
$rsContent = $DB->Query($sql);
if ($arContent = $rsContent->Fetch()) {
$DB->Query("DELETE FROM b_search_content_stem WHERE SEARCH_CONTENT_ID = " . $ID);
CSearch::StemIndex($sites, $ID, $arContent["SEARCHABLE_CONTENT"]);
}
$DB->Query("DELETE FROM b_search_content_stem WHERE SEARCH_CONTENT_ID = " . $stemTask["ID"]);
} else {
//Cancel the agent
return "";
}
} while ($etime >= time());
return "CSearchStemTable::DelayedStemIndex();";
}
示例3: Lookup
public function Lookup()
{
$DB = CDatabase::GetModuleConnection('statistic');
if ($this->city_avail && $this->ip_number) {
$rs = $DB->Query("\n\t\t\t\tSELECT *\n\t\t\t\tFROM b_stat_city_ip\n\t\t\t\tWHERE START_IP = (\n\t\t\t\t\tSELECT MAX(START_IP)\n\t\t\t\t\tFROM b_stat_city_ip\n\t\t\t\t\tWHERE START_IP <= " . $this->ip_number . "\n\t\t\t\t)\n\t\t\t\tAND END_IP >= " . $this->ip_number . "\n\t\t\t", true);
if ($rs) {
$ar = $rs->Fetch();
if ($ar) {
$this->country_code = $ar["COUNTRY_ID"];
$this->city_id = $ar["CITY_ID"];
}
} else {
//Here is mysql 4.0 version which does not supports subqueries
//and not smart to optimeze query
$rs = $DB->Query("\n\t\t\t\t\tSELECT START_IP\n\t\t\t\t\tFROM b_stat_city_ip\n\t\t\t\t\tWHERE START_IP <= " . $this->ip_number . "\n\t\t\t\t\tORDER BY START_IP DESC\n\t\t\t\t\tLIMIT 1\n\t\t\t\t");
$ar = $rs->Fetch();
if ($ar && strlen($ar["START_IP"]) > 0) {
$rs = $DB->Query("\n\t\t\t\t\t\tSELECT *\n\t\t\t\t\t\tFROM b_stat_city_ip\n\t\t\t\t\t\tWHERE START_IP = " . $ar["START_IP"] . "\n\t\t\t\t\t\tAND END_IP >= " . $this->ip_number . "\n\t\t\t\t\t");
$ar = $rs->Fetch();
if ($ar) {
$this->country_code = $ar["COUNTRY_ID"];
$this->city_id = $ar["CITY_ID"];
}
}
}
}
if (!$this->country_code && $this->country_avail) {
$this->country_code = i2c_get_country();
}
}
示例4: GetList
function GetList(&$by, &$order, $arFilter = array(), &$is_filtered)
{
$err_mess = "File: " . __FILE__ . "<br>Line: ";
$DB = CDatabase::GetModuleConnection('statistic');
$arSqlSearch = array();
$strSqlSearch = "";
if (is_array($arFilter)) {
foreach ($arFilter as $key => $val) {
if (is_array($val)) {
if (count($val) <= 0) {
continue;
}
} else {
if (strlen($val) <= 0 || $val === "NOT_REF") {
continue;
}
}
$match_value_set = array_key_exists($key . "_EXACT_MATCH", $arFilter);
$key = strtoupper($key);
switch ($key) {
case "LAST":
$arSqlSearch[] = $val == "Y" ? "S.DATE_STAT = curdate()" : "S.DATE_STAT<>curdate()";
break;
case "USER_AGENT":
$match = $arFilter[$key . "_EXACT_MATCH"] == "Y" && $match_value_set ? "N" : "Y";
$arSqlSearch[] = GetFilterQuery("S.USER_AGENT", $val, $match);
break;
case "COUNTER1":
$arSqlSearch_h[] = "COUNTER>=" . intval($val);
break;
case "COUNTER2":
$arSqlSearch_h[] = "COUNTER<=" . intval($val);
break;
}
}
for ($i = 0; $i < count($arSqlSearch_h); $i++) {
$strSqlSearch_h .= " and (" . $arSqlSearch_h[$i] . ") ";
}
}
if ($by == "s_user_agent") {
$strSqlOrder = "ORDER BY S.USER_AGENT";
} elseif ($by == "s_counter") {
$strSqlOrder = "ORDER BY COUNTER";
} else {
$by = "s_counter";
$strSqlOrder = "ORDER BY COUNTER";
}
if ($order != "asc") {
$strSqlOrder .= " desc ";
$order = "desc";
}
$strSqlSearch = GetFilterSqlSearch($arSqlSearch);
$strSql = "SET OPTION SQL_BIG_SELECTS=1";
$res = $DB->Query($strSql, false, $err_mess . __LINE__);
$strSql = "\n\t\t\tSELECT\n\t\t\t\tS.USER_AGENT,\n\t\t\t\tcount(S.ID) COUNTER\n\t\t\tFROM\n\t\t\t\tb_stat_session S\n\t\t\tLEFT JOIN b_stat_browser B ON (\n\t\t\t\tlength(B.USER_AGENT)>0\n\t\t\tand B.USER_AGENT is not null\n\t\t\tand\tupper(S.USER_AGENT) like upper(B.USER_AGENT)\n\t\t\t)\n\t\t\tLEFT JOIN b_stat_searcher R ON (\n\t\t\t\tlength(R.USER_AGENT)>0\n\t\t\tand\tR.USER_AGENT is not null\n\t\t\tand\tupper(S.USER_AGENT) like upper(concat('%',R.USER_AGENT,'%'))\n\t\t\t)\n\t\t\tWHERE\n\t\t\t{$strSqlSearch}\n\t\t\tand S.USER_AGENT is not null\n\t\t\tand S.USER_AGENT<>''\n\t\t\tand S.NEW_GUEST<>'N'\n\t\t\tand B.ID is null\n\t\t\tand R.ID is null\n\t\t\tGROUP BY S.USER_AGENT\n\t\t\tHAVING '1'='1' {$strSqlSearch_h}\n\t\t\t{$strSqlOrder}\n\t\t\t";
$res = $DB->Query($strSql, false, $err_mess . __LINE__);
$is_filtered = IsFiltered($strSqlSearch) || strlen($strSqlSearch_h) > 0;
return $res;
}
示例5: Search
function Search($phrase = "", $nTopCount = 5, $arParams = array(), $bNotFilter = false, $order = "")
{
$DB = CDatabase::GetModuleConnection('search');
$this->_arPhrase = stemming_split($phrase, LANGUAGE_ID);
if(!empty($this->_arPhrase))
{
$nTopCount = intval($nTopCount);
if($nTopCount <= 0)
$nTopCount = 5;
$arId = CSearchFullText::GetInstance()->searchTitle($phrase, $this->_arPhrase, $nTopCount, $arParams, $bNotFilter, $order);
if (!is_array($arId))
{
return $this->searchTitle($phrase, $nTopCount, $arParams, $bNotFilter, $order);
}
elseif (!empty($arId))
{
$strSql = "
SELECT
sc.ID
,sc.MODULE_ID
,sc.ITEM_ID
,sc.TITLE
,sc.PARAM1
,sc.PARAM2
,sc.DATE_CHANGE
,L.DIR
,L.SERVER_NAME
,sc.URL as URL
,scsite.URL as SITE_URL
,scsite.SITE_ID
,if(locate('".$DB->ForSQL(ToUpper($phrase))."', upper(sc.TITLE)) > 0, 1, 0) RANK1
FROM
b_search_content sc
INNER JOIN b_search_content_site scsite ON sc.ID = scsite.SEARCH_CONTENT_ID
INNER JOIN b_lang L ON scsite.SITE_ID = L.LID
WHERE
sc.ID in (".implode(",", $arId).")
and scsite.SITE_ID = '".SITE_ID."'
ORDER BY ".(
$bOrderByRank?
"RANK1 DESC, TITLE":
"DATE_CHANGE DESC, RANK1 DESC, TITLE"
)."
";
$r = $DB->Query($DB->TopSql($strSql, $nTopCount+1));
parent::CDBResult($r);
return true;
}
}
else
{
return false;
}
}
示例6: GetURLs
public static function GetURLs($site_id, $ID, $limit = 0)
{
$DB = CDatabase::GetModuleConnection('search');
$strSql = "\n\t\tSELECT\n\t\t\tsc.ID\n\t\t\t,sc.MODULE_ID\n\t\t\t,sc.ITEM_ID\n\t\t\t,sc.TITLE\n\t\t\t,sc.PARAM1\n\t\t\t,sc.PARAM2\n\t\t\t,sc.UPD\n\t\t\t,sc.DATE_FROM\n\t\t\t,sc.DATE_TO\n\t\t\t,L.DIR\n\t\t\t,L.SERVER_NAME\n\t\t\t,sc.URL as URL\n\t\t\t,scsite.URL as SITE_URL\n\t\t\t,scsite.SITE_ID\n\t\t\t," . $DB->DateToCharFunction("sc.DATE_CHANGE") . " as FULL_DATE_CHANGE\n\t\t\t," . $DB->DateToCharFunction("sc.DATE_CHANGE", "SHORT") . " as DATE_CHANGE\n\t\tFROM\tb_search_content sc\n\t\t\tINNER JOIN b_search_content_site scsite ON sc.ID=scsite.SEARCH_CONTENT_ID\n\t\t\tINNER JOIN b_lang L ON scsite.SITE_ID=L.LID\n\t\t\tINNER JOIN b_search_content_right scg ON sc.ID=scg.SEARCH_CONTENT_ID\n\t\tWHERE\n\t\t\tscg.GROUP_CODE='G2'\n\t\t\tAND scsite.SITE_ID='" . $DB->ForSQL($site_id, 2) . "'\n\t\t\tAND (sc.DATE_FROM is null OR sc.DATE_FROM <= " . $DB->CurrentTimeFunction() . ")\n\t\t\tAND (sc.DATE_TO is null OR sc.DATE_TO >= " . $DB->CurrentTimeFunction() . ")\n\t\t\tAND sc.ID > " . intval($ID) . "\n\t\tORDER BY\n\t\t\tsc.ID\n\t\t";
if (intval($limit) > 0) {
$strSql .= "LIMIT " . intval($limit);
}
$r = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
parent::CDBResult($r->result);
}
示例7: SetGroups
function SetGroups($arGroups)
{
$DB = CDatabase::GetModuleConnection('search');
$dbCodes = $DB->Query("\n\t\t\tSELECT GROUP_CODE\n\t\t\tFROM b_search_user_right\n\t\t\tWHERE USER_ID = " . $this->_user_id . "\n\t\t", false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
while ($dbCode = $dbCodes->Fetch()) {
if (!in_array($dbCode["GROUP_CODE"], $arGroups)) {
$DB->Query("\n\t\t\t\t\tDELETE FROM b_search_user_right\n\t\t\t\t\tWHERE USER_ID = " . $this->_user_id . "\n\t\t\t\t\tAND GROUP_CODE = '" . $DB->ForSQL($dbCode["GROUP_CODE"]) . "'\n\t\t\t\t", false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
}
}
$this->AddGroups($arGroups);
}
示例8: addAsSearcher
function addAsSearcher($mask)
{
$statDB = CDatabase::GetModuleConnection('statistic');
if (!checkIfBrowser($mask) && !checkIfSearcher($mask)) {
$arFields = array("ACTIVE" => "'Y'", "SAVE_STATISTIC" => "'Y'", "NAME" => "'" . $statDB->ForSql($mask, 255) . "'", "USER_AGENT" => "'" . $statDB->ForSql($mask, 255) . "'");
$statDB->Insert("b_stat_searcher", $arFields);
return 1;
} else {
return 0;
}
}
示例9: AddGroups
function AddGroups($arGroups)
{
$DB = CDatabase::GetModuleConnection('search');
$arToInsert = array();
foreach ($arGroups as $group_code) {
if (strlen($group_code)) {
$arToInsert[$group_code] = $group_code;
}
}
foreach ($arToInsert as $group_code) {
$DB->Query("\n\t\t\t\tINSERT INTO b_search_user_right\n\t\t\t\t(USER_ID, GROUP_CODE)\n\t\t\t\tVALUES\n\t\t\t\t(" . $this->_user_id . ", '" . $DB->ForSQL($group_code, 100) . "')\n\t\t\t", true, "File: " . __FILE__ . "<br>Line: " . __LINE__);
}
}
示例10: Search
function Search($phrase = "", $nTopCount = 5, $arParams = array(), $bNotFilter = false, $order = "")
{
$DB = CDatabase::GetModuleConnection('search');
$this->_arPhrase = stemming_split($phrase, LANGUAGE_ID);
if (!empty($this->_arPhrase)) {
$nTopCount = intval($nTopCount);
if ($nTopCount <= 0) {
$nTopCount = 5;
}
$arId = CSearchFullText::GetInstance()->searchTitle($phrase, $this->_arPhrase, $nTopCount, $arParams, $bNotFilter, $order);
if (!is_array($arId)) {
return $this->searchTitle($phrase, $nTopCount, $arParams, $bNotFilter, $order);
} elseif (!empty($arId)) {
$strSql = "\n\t\t\t\t\tSELECT\n\t\t\t\t\t\tsc.ID\n\t\t\t\t\t\t,sc.MODULE_ID\n\t\t\t\t\t\t,sc.ITEM_ID\n\t\t\t\t\t\t,sc.TITLE\n\t\t\t\t\t\t,sc.PARAM1\n\t\t\t\t\t\t,sc.PARAM2\n\t\t\t\t\t\t,sc.DATE_CHANGE\n\t\t\t\t\t\t,L.DIR\n\t\t\t\t\t\t,L.SERVER_NAME\n\t\t\t\t\t\t,sc.URL as URL\n\t\t\t\t\t\t,scsite.URL as SITE_URL\n\t\t\t\t\t\t,scsite.SITE_ID\n\t\t\t\t\t\t," . $this->getRankFunction($phrase) . " RANK1\n\t\t\t\t\tFROM\n\t\t\t\t\t\tb_search_content sc\n\t\t\t\t\t\tINNER JOIN b_search_content_site scsite ON sc.ID = scsite.SEARCH_CONTENT_ID\n\t\t\t\t\t\tINNER JOIN b_lang L ON scsite.SITE_ID = L.LID\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tsc.ID in (" . implode(",", $arId) . ")\n\t\t\t\t\t\tand scsite.SITE_ID = '" . SITE_ID . "'\n\t\t\t\t\tORDER BY " . $this->getSqlOrder($bOrderByRank) . "\n\t\t\t\t";
$r = $DB->Query($DB->TopSql($strSql, $nTopCount + 1));
parent::CDBResult($r);
return true;
}
} else {
return false;
}
}
示例11: Search
function Search($phrase = "", $nTopCount = 5, $arParams = array(), $bNotFilter = false, $order = "")
{
$DB = CDatabase::GetModuleConnection('search');
$this->_arPhrase = stemming_split($phrase, LANGUAGE_ID);
$bOrderByRank = $order == "rank";
if (!empty($this->_arPhrase)) {
$nTopCount = intval($nTopCount);
if ($nTopCount <= 0) {
$nTopCount = 5;
}
$sqlHaving = array();
$sqlWords = array();
foreach (array_reverse($this->_arPhrase, true) as $word => $pos) {
if (empty($sqlWords) && !preg_match("/[\\n\\r \\t]\$/", $phrase)) {
$s = $sqlWords[] = "ct.WORD like '" . $DB->ForSQL($word) . "%'";
} else {
$s = $sqlWords[] = "ct.WORD = '" . $DB->ForSQL($word) . "'";
}
$sqlHaving[] = "(sum(" . $s . ") > 0)";
}
$bIncSites = false;
$strSqlWhere = CSearch::__PrepareFilter($arParams, $bIncSites);
if ($bNotFilter) {
if (!empty($strSqlWhere)) {
$strSqlWhere = "NOT (" . $strSqlWhere . ")";
} else {
$strSqlWhere = "1=0";
}
}
$strSql = "\n\t\t\t\tSELECT\n\t\t\t\t\tsc.ID\n\t\t\t\t\t,sc.MODULE_ID\n\t\t\t\t\t,sc.ITEM_ID\n\t\t\t\t\t,sc.TITLE\n\t\t\t\t\t,sc.PARAM1\n\t\t\t\t\t,sc.PARAM2\n\t\t\t\t\t,sc.DATE_CHANGE\n\t\t\t\t\t,L.DIR\n\t\t\t\t\t,L.SERVER_NAME\n\t\t\t\t\t,sc.URL as URL\n\t\t\t\t\t,scsite.URL as SITE_URL\n\t\t\t\t\t,scsite.SITE_ID\n\t\t\t\t\t,if(locate('" . $DB->ForSQL(ToUpper($phrase)) . "', upper(sc.TITLE)) > 0, 1, 0) RANK1\n\t\t\t\t\t,count(1) RANK2\n\t\t\t\t\t,min(ct.POS) RANK3\n\t\t\t\tFROM\n\t\t\t\t\tb_search_content_title ct\n\t\t\t\t\tINNER JOIN b_lang L ON ct.SITE_ID = L.LID\n\t\t\t\t\tinner join b_search_content sc on sc.ID = ct.SEARCH_CONTENT_ID\n\t\t\t\t\tINNER JOIN b_search_content_site scsite ON sc.ID = scsite.SEARCH_CONTENT_ID and ct.SITE_ID = scsite.SITE_ID\n\t\t\t\tWHERE\n\t\t\t\t\t" . CSearch::CheckPermissions("sc.ID") . "\n\t\t\t\t\tAND ct.SITE_ID = '" . SITE_ID . "'\n\t\t\t\t\tAND (" . implode(" OR ", $sqlWords) . ")\n\t\t\t\t\t" . (!empty($strSqlWhere) ? "AND " . $strSqlWhere : "") . "\n\t\t\t\tGROUP BY\n\t\t\t\t\tID, MODULE_ID, ITEM_ID, TITLE, PARAM1, PARAM2, DATE_CHANGE, DIR, SERVER_NAME, URL, SITE_URL, SITE_ID\n\t\t\t\t" . (count($sqlHaving) > 1 ? "HAVING " . implode(" AND ", $sqlHaving) : "") . "\n\t\t\t\tORDER BY " . ($bOrderByRank ? "RANK1 DESC, RANK2 DESC, RANK3 ASC, TITLE" : "DATE_CHANGE DESC, RANK1 DESC, RANK2 DESC, RANK3 ASC, TITLE") . "\n\t\t\t\tLIMIT 0, " . ($nTopCount + 1) . "\n\t\t\t";
$r = $DB->Query($strSql);
parent::CDBResult($r);
return true;
} else {
return false;
}
}
示例12: CheckFDate
function CheckFDate($date, $mess)
{
global $strError;
if (strlen($date) > 0) {
$str = "";
if (!CheckDateTime($date)) {
$str .= $mess . "<br>";
}
$strError .= $str;
if (strlen($str) > 0) {
return false;
}
}
return true;
}
$statDB = CDatabase::GetModuleConnection('statistic');
$err_mess = "FILE: " . __FILE__ . "<br>\nLINE: ";
$module_id = "statistic";
$STAT_RIGHT = $APPLICATION->GetGroupRight($module_id);
$strError = "";
if ($STAT_RIGHT >= "R") {
$aTabs = array(array("DIV" => "edit1", "TAB" => GetMessage("MAIN_TAB_SET"), "ICON" => "statistic_settings", "TITLE" => GetMessage("MAIN_TAB_TITLE_SET")), array("DIV" => "edit6", "TAB" => GetMessage("STAT_OPT_TAB_ADV"), "ICON" => "statistic_settings", "TITLE" => GetMessage("STAT_OPT_TAB_ADV_TITLE")), array("DIV" => "edit7", "TAB" => GetMessage("STAT_OPT_TAB_CITY"), "ICON" => "statistic_settings", "TITLE" => GetMessage("STAT_OPT_TAB_CITY_TITLE")), array("DIV" => "edit2", "TAB" => GetMessage("STAT_OPT_TAB_STORAGE"), "ICON" => "statistic_settings", "TITLE" => GetMessage("STAT_OPT_TAB_STORAGE_TITLE")), array("DIV" => "edit3", "TAB" => GetMessage("STAT_OPT_TAB_TIME"), "ICON" => "statistic_settings", "TITLE" => GetMessage("STAT_OPT_TAB_TIME_TITLE")), array("DIV" => "edit4", "TAB" => GetMessage("STAT_OPT_TAB_SKIP"), "ICON" => "statistic_settings", "TITLE" => GetMessage("STAT_OPT_TAB_SKIP_TITLE")), array("DIV" => "edit5", "TAB" => GetMessage("MAIN_TAB_RIGHTS"), "ICON" => "statistic_settings", "TITLE" => GetMessage("MAIN_TAB_TITLE_RIGHTS")));
$tabControl = new CAdminTabControl("tabControl", $aTabs);
$aTabs = array(array("DIV" => "fedit2", "TAB" => GetMessage("STAT_OPT_TAB_CLEANUP"), "ICON" => "statistic_settings", "TITLE" => GetMessage("STAT_OPT_TAB_CLEANUP_TITLE")));
if (strtolower($statDB->type) == "mysql") {
$aTabs[] = array("DIV" => "fedit3", "TAB" => GetMessage("STAT_OPT_TAB_OPTIMIZE"), "ICON" => "statistic_settings", "TITLE" => GetMessage("STAT_OPT_TAB_OPTIMIZE_TITLE"));
}
if ($STAT_RIGHT >= "W" && ($bCheckForDDL = CStatistics::CheckForDDL())) {
$aTabs[] = array("DIV" => "fedit4", "TAB" => GetMessage("STAT_OPT_TAB_INDEX"), "ICON" => "statistic_settings", "TITLE" => GetMessage("STAT_OPT_TAB_INDEX_TITLE"));
}
$tabControl2 = new CAdminTabControl("tabControl2", $aTabs, true, true);
示例13: IncParam
function IncParam($arParam, $arParamSite = false, $SITE_ID = false, $DATE = false, $DATE_FORMAT = "FULL", $SIGN = "+")
{
$DB = CDatabase::GetModuleConnection('statistic');
if ($DATE == false) {
$strWhere = "WHERE " . CStatistics::DBDateCompare("DATE_STAT");
$stmp = time();
} else {
$stmp = MakeTimeStamp($DATE, $DATE_FORMAT == "SHORT" ? FORMAT_DATE : FORMAT_DATETIME);
$strWhere = "WHERE " . CStatistics::DBDateCompare("DATE_STAT", ConvertTimeStamp($stmp));
}
$HOUR = date("G", $stmp);
// 0..23
$WEEKDAY = date("w", $stmp);
// 0..6
$MONTH = date("n", $stmp);
// 1..12
static $arKeys = array("HOUR", "WEEKDAY", "MONTH");
static $arPreKeys = array("HITS" => 0, "FAVORITES" => 0, "SESSIONS" => 0, "C_HOSTS" => 0, "GUESTS" => 0, "NEW_GUESTS" => 0);
$rows = false;
if (is_array($arParam) && count($arParam) > 0) {
if (array_key_exists("TOTAL_HOSTS", $arParam)) {
unset($arParam["TOTAL_HOSTS"]);
}
$arFields = array();
foreach ($arParam as $name => $value) {
if (array_key_exists($name, $arPreKeys)) {
$arFields[$name] = $name . " + " . intval($value);
} else {
foreach ($arKeys as $key) {
$k = $key . "_" . $name . "_" . ${$key};
$arFields[$k] = "{$k} " . ($SIGN === "-" ? "-" : "+") . " " . intval($value);
}
}
}
if (count($arFields) > 0) {
$rows = $DB->Update("b_stat_day", $arFields, $strWhere);
}
}
if ($SITE_ID === false) {
$SITE_ID = "";
if (defined("ADMIN_SECTION") && ADMIN_SECTION === true) {
$SITE_ID = "";
} elseif (defined("SITE_ID")) {
$SITE_ID = SITE_ID;
}
}
if (strlen($SITE_ID) > 0 && is_array($arParamSite) && count($arParamSite) > 0) {
$arFields = array();
foreach ($arParamSite as $name => $value) {
if (array_key_exists($name, $arPreKeys)) {
$arFields[$name] = $name . " + " . intval($value);
} else {
foreach ($arKeys as $key) {
$k = $key . "_" . $name . "_" . ${$key};
$arFields[$k] = "{$k} " . ($SIGN === "-" ? "-" : "+") . " " . intval($value);
}
}
}
if (count($arFields) > 0) {
$rows = $DB->Update("b_stat_day_site", $arFields, $strWhere . " AND SITE_ID='" . $DB->ForSql($SITE_ID, 2) . "'");
}
}
return $rows;
}
示例14: SetNewDay
function SetNewDay($HOSTS = 0, $TOTAL_HOSTS = 0, $SESSIONS = 0, $HITS = 0, $NEW_GUESTS = 0, $GUESTS = 0, $FAVORITES = 0)
{
__SetNoKeepStatistics();
if ($_SESSION["SESS_NO_AGENT_STATISTIC"] != "Y" && !defined("NO_AGENT_STATISTIC")) {
$err_mess = "File: " . __FILE__ . "<br>Line: ";
$DB = CDatabase::GetModuleConnection('statistic');
$strSql = "SELECT D.ID FROM b_stat_day D WHERE D.DATE_STAT=CURDATE()";
$rs = $DB->Query($strSql, false, $err_mess . __LINE__);
if (!$rs->Fetch()) {
$arFields = array("DATE_STAT" => "curdate()", "C_HOSTS" => intval($HOSTS), "SESSIONS" => intval($SESSIONS), "GUESTS" => intval($GUESTS), "HITS" => intval($HITS), "FAVORITES" => intval($FAVORITES), "NEW_GUESTS" => intval($NEW_GUESTS));
$ID = $DB->Insert("b_stat_day", $arFields, $err_mess . __LINE__, false, "", true);
}
//Calculate attentiveness for yesturday
$strSql = "\n\t\t\t\tSELECT D.ID, " . $DB->DateToCharFunction("D.DATE_STAT", "SHORT") . " DATE_STAT\n\t\t\t\tFROM b_stat_day D\n\t\t\t\tWHERE D.DATE_STAT=DATE_SUB(CURDATE(),INTERVAL 1 DAY)\n\t\t\t";
$rs = $DB->Query($strSql, false, $err_mess . __LINE__);
if ($ar = $rs->Fetch()) {
$arF = CSession::GetAttentiveness($ar["DATE_STAT"]);
if (is_array($arF)) {
$DB->Update("b_stat_day", $arF, "WHERE ID='" . $ar["ID"] . "'", $err_mess . __LINE__);
}
}
}
return "CStatistics::SetNewDay();";
}
示例15: GetList
/**
* <p>Возвращает список <a href="http://dev.1c-bitrix.ru/api_help/statistic/terms.php#session">сессий</a> <a href="http://dev.1c-bitrix.ru/api_help/statistic/terms.php#guest">посетителей</a>, проявивших активность (совершивших <a href="http://dev.1c-bitrix.ru/api_help/statistic/terms.php#hit">хит</a>) на сайте за определённый интервал времени.</p>
*
*
*
*
* @param function $GetList Ссылка на переменную, которая после выполнения функции будет
* содержать количество <a
* href="http://dev.1c-bitrix.ru/api_help/statistic/terms.php#online">посетителей в online</a>.
*
*
*
* @param (&$guest_coun $t Ссылка на переменную, которая после выполнения функции будет
* содержать количество сессий посетителей в online.
*
*
*
* @param &$session_coun $t
*
*
*
* @param $arOrde $r = Array()
*
*
*
* @param $arFilte $r = Array())
*
*
*
* @return CDBResult
*
*
* <h4>Example</h4>
* <pre>
* <?
* // получим список записей
* $rs = <b>CUserOnline::GetList</b>($guest_counter, $session_counter);
*
* echo "Количество посетителей в онлайн: ".$guest_counter;
* echo "Количество сессий в онлайн: ".$session_counter;
*
* // выведем все записи
* while ($ar = $rs->Fetch())
* {
* echo "<pre>"; print_r($ar); echo "</pre>";
* }
* ?>
* </pre>
*
*
*
* <h4>See Also</h4>
* <ul> <li> <a href="http://www.1c-bitrix.ru/user_help/statistic/users_online.php">Отчет "Кто на сайте"</a>
* </li> </ul><a name="examples"></a>
*
*
* @static
* @link http://dev.1c-bitrix.ru/api_help/statistic/classes/cuseronline/getlist.php
* @author Bitrix
*/
public static function GetList(&$guest_count, &$session_count, $arOrder=Array(), $arFilter=Array())
{
$DB = CDatabase::GetModuleConnection('statistic');
$err_mess = "File: ".__FILE__."<br>Line: ";
$interval = intval(COption::GetOptionString("statistic", "ONLINE_INTERVAL"));
$arSqlSearch = Array();
$strSqlSearch = "";
if (is_array($arFilter))
{
foreach ($arFilter as $key => $val)
{
if(is_array($val))
{
if(count($val) <= 0)
continue;
}
else
{
if( (strlen($val) <= 0) || ($val === "NOT_REF") )
continue;
}
$match_value_set = array_key_exists($key."_EXACT_MATCH", $arFilter);
$key = strtoupper($key);
switch($key)
{
case "INTERVAL":
$interval = intval($val);
break;
case "ID":
case "GUEST_ID":
case "ADV_ID":
case "STOP_LIST_ID":
case "USER_ID":
$match = ($arFilter[$key."_EXACT_MATCH"]=="N" && $match_value_set) ? "Y" : "N";
$arSqlSearch[] = GetFilterQuery("S.".$key,$val,$match);
break;
case "COUNTRY_ID":
$match = ($arFilter[$key."_EXACT_MATCH"]=="N" && $match_value_set) ? "Y" : "N";
$arSqlSearch[] = GetFilterQuery("S.COUNTRY_ID",$val,$match);
//.........这里部分代码省略.........