當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CRM_Core_Config::clearTempTables方法代碼示例

本文整理匯總了PHP中CRM_Core_Config::clearTempTables方法的典型用法代碼示例。如果您正苦於以下問題:PHP CRM_Core_Config::clearTempTables方法的具體用法?PHP CRM_Core_Config::clearTempTables怎麽用?PHP CRM_Core_Config::clearTempTables使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在CRM_Core_Config的用法示例。


在下文中一共展示了CRM_Core_Config::clearTempTables方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: cleanup

 /**
  * Do periodic cleanup of the CiviCRM session table.
  *
  * Also delete all session cache entries which are a couple of days old.
  * This keeps the session cache to a manageable size
  *
  * @param bool $session
  * @param bool $table
  * @param bool $prevNext
  */
 public static function cleanup($session = FALSE, $table = FALSE, $prevNext = FALSE)
 {
     // clean up the session cache every $cacheCleanUpNumber probabilistically
     $cleanUpNumber = 757;
     // clean up all sessions older than $cacheTimeIntervalDays days
     $timeIntervalDays = 2;
     $timeIntervalMins = 30;
     if (mt_rand(1, 100000) % $cleanUpNumber == 0) {
         $session = $table = $prevNext = TRUE;
     }
     if (!$session && !$table && !$prevNext) {
         return;
     }
     if ($prevNext) {
         // delete all PrevNext caches
         CRM_Core_BAO_PrevNextCache::cleanupCache();
     }
     if ($table) {
         CRM_Core_Config::clearTempTables($timeIntervalDays . ' day');
     }
     if ($session) {
         // first delete all sessions which are related to any potential transaction
         // page
         $transactionPages = array('CRM_Contribute_Controller_Contribution', 'CRM_Event_Controller_Registration');
         $params = array(1 => array(date('Y-m-d H:i:s', time() - $timeIntervalMins * 60), 'String'));
         foreach ($transactionPages as $trPage) {
             $params[] = array("%{$trPage}%", 'String');
             $where[] = 'path LIKE %' . count($params);
         }
         $sql = "\nDELETE FROM civicrm_cache\nWHERE       group_name = 'CiviCRM Session'\nAND         created_date <= %1\nAND         (" . implode(' OR ', $where) . ")";
         CRM_Core_DAO::executeQuery($sql, $params);
         $sql = "\nDELETE FROM civicrm_cache\nWHERE       group_name = 'CiviCRM Session'\nAND         created_date < date_sub( NOW( ), INTERVAL {$timeIntervalDays} DAY )\n";
         CRM_Core_DAO::executeQuery($sql);
     }
 }
開發者ID:hyebahi,項目名稱:civicrm-core,代碼行數:45,代碼來源:Cache.php


注:本文中的CRM_Core_Config::clearTempTables方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。