本文整理汇总了PHP中CRM_Utils_Date::getUTCTime方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_Date::getUTCTime方法的具体用法?PHP CRM_Utils_Date::getUTCTime怎么用?PHP CRM_Utils_Date::getUTCTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Utils_Date
的用法示例。
在下文中一共展示了CRM_Utils_Date::getUTCTime方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: remove
/**
* Removes all the cache entries pertaining to a specific group.
* If no groupID is passed in, removes cache entries for all groups
* Has an optimization to bypass repeated invocations of this function.
* Note that this function is an advisory, i.e. the removal respects the
* cache date, i.e. the removal is not done if the group was recently
* loaded into the cache.
*
* @param int $groupID
* the groupID to delete cache entries, NULL for all groups.
* @param bool $onceOnly
* run the function exactly once for all groups.
*
* @return void
*/
public static function remove($groupID = NULL, $onceOnly = TRUE)
{
static $invoked = FALSE;
// typically this needs to happy only once per instance
// this is especially TRUE in import, where we dont need
// to do this all the time
// this optimization is done only when no groupID is passed
// i.e. cache is reset for all groups
if ($onceOnly && $invoked && $groupID == NULL) {
return;
}
if ($groupID == NULL) {
$invoked = TRUE;
} elseif (is_array($groupID)) {
foreach ($groupID as $gid) {
unset(self::$_alreadyLoaded[$gid]);
}
} elseif ($groupID && array_key_exists($groupID, self::$_alreadyLoaded)) {
unset(self::$_alreadyLoaded[$groupID]);
}
$refresh = NULL;
$params = array();
$smartGroupCacheTimeout = self::smartGroupCacheTimeout();
$now = CRM_Utils_Date::getUTCTime();
$refreshTime = CRM_Utils_Date::getUTCTime($smartGroupCacheTimeout * 60);
if (!isset($groupID)) {
if ($smartGroupCacheTimeout == 0) {
$query = "\nTRUNCATE civicrm_group_contact_cache\n";
$update = "\nUPDATE civicrm_group g\nSET cache_date = null,\n refresh_date = null\n";
} else {
$query = "\nDELETE gc\nFROM civicrm_group_contact_cache gc\nINNER JOIN civicrm_group g ON g.id = gc.group_id\nWHERE TIMESTAMPDIFF(MINUTE, g.cache_date, {$now}) >= {$smartGroupCacheTimeout}\n";
$update = "\nUPDATE civicrm_group g\nSET cache_date = null,\n refresh_date = null\nWHERE TIMESTAMPDIFF(MINUTE, cache_date, {$now}) >= {$smartGroupCacheTimeout}\n";
$refresh = "\nUPDATE civicrm_group g\nSET refresh_date = {$refreshTime}\nWHERE TIMESTAMPDIFF(MINUTE, cache_date, {$now}) < {$smartGroupCacheTimeout}\nAND refresh_date IS NULL\n";
}
} elseif (is_array($groupID)) {
$groupIDs = implode(', ', $groupID);
$query = "\nDELETE g\nFROM civicrm_group_contact_cache g\nWHERE g.group_id IN ( {$groupIDs} )\n";
$update = "\nUPDATE civicrm_group g\nSET cache_date = null,\n refresh_date = null\nWHERE id IN ( {$groupIDs} )\n";
} else {
$query = "\nDELETE g\nFROM civicrm_group_contact_cache g\nWHERE g.group_id = %1\n";
$update = "\nUPDATE civicrm_group g\nSET cache_date = null,\n refresh_date = null\nWHERE id = %1\n";
$params = array(1 => array($groupID, 'Integer'));
}
CRM_Core_DAO::executeQuery($query, $params);
if ($refresh) {
CRM_Core_DAO::executeQuery($refresh, $params);
}
// also update the cache_date for these groups
CRM_Core_DAO::executeQuery($update, $params);
}
示例2: resetCache
/**
* Deletes all the cache entries.
*/
public static function resetCache()
{
// reset any static caching
self::$_cache = NULL;
// reset any db caching
$config = CRM_Core_Config::singleton();
$smartGroupCacheTimeout = CRM_Contact_BAO_GroupContactCache::smartGroupCacheTimeout();
//make sure to give original timezone settings again.
$now = CRM_Utils_Date::getUTCTime();
$query = "\nDELETE\nFROM civicrm_acl_cache\nWHERE modified_date IS NULL\n OR (TIMESTAMPDIFF(MINUTE, modified_date, {$now}) >= {$smartGroupCacheTimeout})\n";
CRM_Core_DAO::singleValueQuery($query);
// CRM_Core_DAO::singleValueQuery("TRUNCATE TABLE civicrm_acl_contact_cache"); // No, force-commits transaction
// CRM_Core_DAO::singleValueQuery("DELETE FROM civicrm_acl_contact_cache"); // Transaction-safe
if (CRM_Core_Transaction::isActive()) {
CRM_Core_Transaction::addCallback(CRM_Core_Transaction::PHASE_POST_COMMIT, function () {
CRM_Core_DAO::singleValueQuery("TRUNCATE TABLE civicrm_acl_contact_cache");
});
} else {
CRM_Core_DAO::singleValueQuery("TRUNCATE TABLE civicrm_acl_contact_cache");
}
}