本文整理汇总了PHP中CDatabase::DatetimeToTimestampFunction方法的典型用法代码示例。如果您正苦于以下问题:PHP CDatabase::DatetimeToTimestampFunction方法的具体用法?PHP CDatabase::DatetimeToTimestampFunction怎么用?PHP CDatabase::DatetimeToTimestampFunction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CDatabase
的用法示例。
在下文中一共展示了CDatabase::DatetimeToTimestampFunction方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: IsUserModuleAdmin
function IsUserModuleAdmin($userID, $site_id = SITE_ID)
{
global $DB, $CACHE_MANAGER;
static $arSocnetModuleAdminsCache = array();
if ($userID <= 0) {
return false;
}
if ($site_id && !is_array($site_id)) {
$site_id = array($site_id, false);
} elseif ($site_id && is_array($site_id)) {
$site_id = array_merge($site_id, array(false));
}
$cache_key = serialize($site_id);
if (!array_key_exists($cache_key, $arSocnetModuleAdminsCache)) {
$cache = new CPHPCache();
$cache_time = 31536000;
$cache_id = 'site' . ($site_id ? '_' . implode('|', $site_id) : '');
$cache_path = "/sonet/user_admin/";
$arModuleAdmins = array();
if ($cache->InitCache($cache_time, $cache_id, $cache_path)) {
$arCacheVars = $cache->GetVars();
$arModuleAdmins = $arCacheVars["RESULT"];
} else {
$cache->StartDataCache($cache_time, $cache_id, $cache_path);
if (!$site_id) {
$strSqlSite = "AND MG.SITE_ID IS NULL";
} else {
$strSqlSite = " AND (";
foreach ($site_id as $i => $site_id_tmp) {
if ($i > 0) {
$strSqlSite .= " OR ";
}
$strSqlSite .= "MG.SITE_ID " . ($site_id_tmp ? "= '" . $DB->ForSQL($site_id_tmp) . "'" : "IS NULL");
}
$strSqlSite .= ")";
}
$strSql = "SELECT " . "UG.USER_ID U_ID, " . "G.ID G_ID, " . CDatabase::DatetimeToTimestampFunction("UG.DATE_ACTIVE_FROM") . " UG_DATE_FROM_TS, " . CDatabase::DatetimeToTimestampFunction("UG.DATE_ACTIVE_TO") . " UG_DATE_TO_TS, " . "MAX(MG.G_ACCESS) G_ACCESS " . "FROM b_user_group UG, b_module_group MG, b_group G " . "WHERE " . "\t(G.ID = MG.GROUP_ID or G.ID = 1) " . "\tAND MG.MODULE_ID = 'socialnetwork' " . "\tAND G.ID = UG.GROUP_ID " . "\tAND G.ACTIVE = 'Y' " . "\tAND G_ACCESS >= 'W'\t" . "\tAND (G.ANONYMOUS<>'Y' OR G.ANONYMOUS IS NULL) " . $strSqlSite . " " . "GROUP BY " . "\tUG.USER_ID, G.ID";
$result = $DB->Query($strSql, false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__);
while ($ar = $result->Fetch()) {
if (!array_key_exists($ar["U_ID"], $arModuleAdmins)) {
$arModuleAdmins[$ar["U_ID"]] = array("USER_ID" => $ar["U_ID"], "DATE_FROM_TS" => $ar["UG_DATE_FROM_TS"], "DATE_TO_TS" => $ar["UG_DATE_TO_TS"]);
}
}
}
$arCacheData = array("RESULT" => $arModuleAdmins);
$cache->EndDataCache($arCacheData);
foreach ($arModuleAdmins as $key => $arUserData) {
if (!empty($arUserData["DATE_FROM_TS"]) && $arUserData["DATE_FROM_TS"] > time() || !empty($arUserData["DATE_TO_TS"]) && $arUserData["DATE_TO_TS"] < time()) {
unset($arModuleAdmins[$key]);
}
}
$arSocnetModuleAdminsCache[$cache_key] = $arModuleAdmins;
}
return array_key_exists($userID, $arSocnetModuleAdminsCache[$cache_key]);
}