本文整理汇总了PHP中Piwik\DataAccess\ArchiveTableCreator::getTypeFromTableName方法的典型用法代码示例。如果您正苦于以下问题:PHP ArchiveTableCreator::getTypeFromTableName方法的具体用法?PHP ArchiveTableCreator::getTypeFromTableName怎么用?PHP ArchiveTableCreator::getTypeFromTableName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik\DataAccess\ArchiveTableCreator
的用法示例。
在下文中一共展示了ArchiveTableCreator::getTypeFromTableName方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAllArchiveBlobTables
/**
* Returns all available archive blob tables
*
* @return array
*/
public static function getAllArchiveBlobTables()
{
if (empty(self::$archiveBlobTables)) {
$archiveTables = ArchiveTableCreator::getTablesArchivesInstalled();
self::$archiveBlobTables = array_filter($archiveTables, function ($name) {
return ArchiveTableCreator::getTypeFromTableName($name) == ArchiveTableCreator::BLOB_TABLE;
});
// sort tables so we have them in order of their date
rsort(self::$archiveBlobTables);
}
return (array) self::$archiveBlobTables;
}
示例2: getMigrations
public function getMigrations(Updater $updater)
{
$migrations = array();
$archiveTables = ArchiveTableCreator::getTablesArchivesInstalled();
$archiveBlobTables = array_filter($archiveTables, function ($name) {
return ArchiveTableCreator::getTypeFromTableName($name) == ArchiveTableCreator::BLOB_TABLE;
});
foreach ($archiveBlobTables as $table) {
$migrations[] = $this->migration->db->sql("UPDATE {$table} SET name = 'DevicePlugins_plugin' WHERE name = 'UserSettings_plugin'");
}
return $migrations;
}
示例3: getMigrationQueries
public function getMigrationQueries(Updater $updater)
{
$sqls = array();
$archiveTables = ArchiveTableCreator::getTablesArchivesInstalled();
$archiveBlobTables = array_filter($archiveTables, function ($name) {
return ArchiveTableCreator::getTypeFromTableName($name) == ArchiveTableCreator::BLOB_TABLE;
});
foreach ($archiveBlobTables as $table) {
$sqls["UPDATE " . $table . " SET name = 'UserLanguage_language' WHERE name = 'UserSettings_language'"] = false;
}
return $sqls;
}
示例4: getSql
public static function getSql()
{
$sqls = array();
$archiveTables = ArchiveTableCreator::getTablesArchivesInstalled();
$archiveBlobTables = array_filter($archiveTables, function ($name) {
return ArchiveTableCreator::getTypeFromTableName($name) == ArchiveTableCreator::BLOB_TABLE;
});
foreach ($archiveBlobTables as $table) {
$sqls["UPDATE " . $table . " SET name = 'DevicePlugins_plugin' WHERE name = 'UserSettings_plugin'"] = false;
}
return $sqls;
}
示例5: addArchivingIdMigrationQueries
private function addArchivingIdMigrationQueries($sql)
{
$tables = ArchiveTableCreator::getTablesArchivesInstalled();
foreach ($tables as $table) {
$type = ArchiveTableCreator::getTypeFromTableName($table);
if ($type === ArchiveTableCreator::NUMERIC_TABLE) {
$maxId = Db::fetchOne('SELECT MAX(idarchive) FROM ' . $table);
if (!empty($maxId)) {
$maxId = (int) $maxId + 500;
} else {
$maxId = 1;
}
$sql[] = $this->migration->db->insert($this->sequenceTable, array('name' => $table, 'value' => $maxId));
}
}
return $sql;
}
示例6: addArchivingIdMigrationQueries
private static function addArchivingIdMigrationQueries($sql)
{
$tables = ArchiveTableCreator::getTablesArchivesInstalled();
foreach ($tables as $table) {
$type = ArchiveTableCreator::getTypeFromTableName($table);
if ($type === ArchiveTableCreator::NUMERIC_TABLE) {
$maxId = Db::fetchOne('SELECT MAX(idarchive) FROM ' . $table);
if (!empty($maxId)) {
$maxId = (int) $maxId + 500;
} else {
$maxId = 1;
}
$query = self::getQueryToCreateSequence($table, $maxId);
// refs #6696, ignores Integrity constraint violation: 1062 Duplicate entry 'piwik_archive_numeric_2010_01' for key 'PRIMARY'
$sql[$query] = '1062';
}
}
return $sql;
}
示例7: createArchiveTable
public function createArchiveTable($tableName, $tableNamePrefix)
{
$db = Db::get();
$sql = DbHelper::getTableCreateSql($tableNamePrefix);
// replace table name template by real name
$tableNamePrefix = Common::prefixTable($tableNamePrefix);
$sql = str_replace($tableNamePrefix, $tableName, $sql);
try {
$db->query($sql);
} catch (Exception $e) {
// accept mysql error 1050: table already exists, throw otherwise
if (!$db->isErrNo($e, '1050')) {
throw $e;
}
}
try {
if (ArchiveTableCreator::NUMERIC_TABLE === ArchiveTableCreator::getTypeFromTableName($tableName)) {
$sequence = new Sequence($tableName);
$sequence->create();
}
} catch (Exception $e) {
}
}
示例8: markArchivesInvalidatedFor
/**
* @param $idSites
* @param $period string
* @param $datesByMonth array
* @throws \Exception
*/
private function markArchivesInvalidatedFor($idSites, $period, $datesByMonth)
{
$invalidateForPeriodId = $this->getPeriodId($period);
// In each table, invalidate day/week/month/year containing this date
$archiveTables = ArchiveTableCreator::getTablesArchivesInstalled();
$archiveNumericTables = array_filter($archiveTables, function ($name) {
return ArchiveTableCreator::getTypeFromTableName($name) == ArchiveTableCreator::NUMERIC_TABLE;
});
foreach ($archiveNumericTables as $table) {
// Extract Y_m from table name
$suffix = ArchiveTableCreator::getDateFromTableName($table);
if (!isset($datesByMonth[$suffix])) {
continue;
}
// Dates which are to be deleted from this table
$datesToDelete = $datesByMonth[$suffix];
self::getModel()->updateArchiveAsInvalidated($table, $idSites, $invalidateForPeriodId, $datesToDelete);
}
}
示例9: getArchiveTablesToPurge
/**
* Utility function that finds every archive table whose reports are considered
* old.
*
* @return array An array of two arrays. The first holds the numeric archive table
* names, and the second holds the blob archive table names.
*/
private function getArchiveTablesToPurge()
{
// get month for which reports as old or older than, should be deleted
// reports whose creation date <= this month will be deleted
// (NOTE: we ignore how far we are in the current month)
$toRemoveDate = Date::factory('today')->subMonth(1 + $this->deleteReportsOlderThan);
// find all archive tables that are older than N months
$oldNumericTables = array();
$oldBlobTables = array();
foreach (DbHelper::getTablesInstalled() as $table) {
$type = ArchiveTableCreator::getTypeFromTableName($table);
if ($type === false) {
continue;
}
$date = ArchiveTableCreator::getDateFromTableName($table);
list($year, $month) = explode('_', $date);
if (self::shouldReportBePurged($year, $month, $toRemoveDate)) {
if ($type == ArchiveTableCreator::NUMERIC_TABLE) {
$oldNumericTables[] = $table;
} else {
$oldBlobTables[] = $table;
}
}
}
return array($oldNumericTables, $oldBlobTables);
}