createArchiveTable($tableName, $tableNamePrefix); self::$tablesAlreadyInstalled[] = $tableName; } } private static function getModel() { return new Model(); } public static function clear() { self::$tablesAlreadyInstalled = null; } public static function refreshTableList() { self::$tablesAlreadyInstalled = self::getModel()->getInstalledArchiveTables(); } /** * Returns all table names archive_* * * @param string $type The type of table to return. Either `self::NUMERIC_TABLE` or `self::BLOB_TABLE`. * @param bool $forceReload * @return array */ public static function getTablesArchivesInstalled($type = null, $forceReload = false) { if (is_null(self::$tablesAlreadyInstalled) || $forceReload ) { self::refreshTableList(); } if (empty($type)) { return self::$tablesAlreadyInstalled; } else { $tableMatchRegex = '/archive_' . preg_quote($type) . '_/'; } $archiveTables = array(); foreach (self::$tablesAlreadyInstalled as $table) { if (preg_match($tableMatchRegex, $table)) { $archiveTables[] = $table; } } return $archiveTables; } public static function getDateFromTableName($tableName) { $tableName = Common::unprefixTable($tableName); $date = str_replace(array('archive_numeric_', 'archive_blob_'), '', $tableName); return $date; } public static function getTableMonthFromDate(Date $date) { return $date->toString('Y_m'); } public static function getTypeFromTableName($tableName) { if (strpos($tableName, 'archive_numeric_') !== false) { return self::NUMERIC_TABLE; } if (strpos($tableName, 'archive_blob_') !== false) { return self::BLOB_TABLE; } return false; } }