本文整理汇总了PHP中Piwik_Common::unprefixTable方法的典型用法代码示例。如果您正苦于以下问题:PHP Piwik_Common::unprefixTable方法的具体用法?PHP Piwik_Common::unprefixTable怎么用?PHP Piwik_Common::unprefixTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik_Common
的用法示例。
在下文中一共展示了Piwik_Common::unprefixTable方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: invalidateArchivedReports
/**
* When tracking data in the past (using Tracking API), this function
* can be used to invalidate reports for the idSites and dates where new data
* was added.
* DEV: If you call this API, the UI should display the data correctly, but will process
* in real time, which could be very slow after large data imports.
* After calling this function via REST, you can manually force all data
* to be reprocessed by visiting the script as the Super User:
* http://example.net/piwik/misc/cron/archive.php?token_auth=$SUPER_USER_TOKEN_AUTH_HERE
* REQUIREMENTS: On large piwik setups, you will need in PHP configuration: max_execution_time = 0
* We recommend to use an hourly schedule of the script at misc/cron/archive.php
* More information: http://piwik.org/setup-auto-archiving/
*
* @param string $idSites Comma separated list of idSite that have had data imported for the specified dates
* @param string $dates Comma separated list of dates to invalidate for all these websites
* @return array
*/
public function invalidateArchivedReports($idSites, $dates)
{
$idSites = Piwik_Site::getIdSitesFromIdSitesString($idSites);
if (empty($idSites)) {
throw new Exception("Specify a value for &idSites= as a comma separated list of website IDs, for which your token_auth has 'admin' permission");
}
Piwik::checkUserHasAdminAccess($idSites);
// Ensure the specified dates are valid
$toInvalidate = $invalidDates = array();
$dates = explode(',', $dates);
$dates = array_unique($dates);
foreach ($dates as $theDate) {
try {
$date = Piwik_Date::factory($theDate);
} catch (Exception $e) {
$invalidDates[] = $theDate;
continue;
}
if ($date->toString() == $theDate) {
$toInvalidate[] = $date;
} else {
$invalidDates[] = $theDate;
}
}
// Lookup archive tables
$tables = Piwik::getTablesInstalled();
$archiveTables = Piwik::getTablesArchivesInstalled();
// If using the feature "Delete logs older than N days"...
$logsAreDeletedBeforeThisDate = Piwik_Config::getInstance()->Deletelogs['delete_logs_schedule_lowest_interval'];
$logsDeleteEnabled = Piwik_Config::getInstance()->Deletelogs['delete_logs_enable'];
$minimumDateWithLogs = false;
if ($logsDeleteEnabled && $logsAreDeletedBeforeThisDate) {
$minimumDateWithLogs = Piwik_Date::factory('today')->subDay($logsAreDeletedBeforeThisDate);
}
// Given the list of dates, process which tables they should be deleted from
$minDate = false;
$warningDates = $processedDates = array();
/* @var $date Piwik_Date */
foreach ($toInvalidate as $date) {
// we should only delete reports for dates that are more recent than N days
if ($minimumDateWithLogs && $date->isEarlier($minimumDateWithLogs)) {
$warningDates[] = $date->toString();
} else {
$processedDates[] = $date->toString();
}
$month = $date->toString('Y_m');
// For a given date, we must invalidate in the monthly archive table
$datesByMonth[$month][] = $date->toString();
// But also the year stored in January
$year = $date->toString('Y_01');
$datesByMonth[$year][] = $date->toString();
// but also weeks overlapping several months stored in the month where the week is starting
/* @var $week Piwik_Period_Week */
$week = Piwik_Period::factory('week', $date);
$week = $week->getDateStart()->toString('Y_m');
$datesByMonth[$week][] = $date->toString();
// Keep track of the minimum date for each website
if ($minDate === false || $date->isEarlier($minDate)) {
$minDate = $date;
}
}
// In each table, invalidate day/week/month/year containing this date
$sqlIdSites = implode(",", $idSites);
foreach ($archiveTables as $table) {
// Extract Y_m from table name
$suffix = str_replace(array('archive_numeric_', 'archive_blob_'), '', Piwik_Common::unprefixTable($table));
if (!isset($datesByMonth[$suffix])) {
continue;
}
// Dates which are to be deleted from this table
$datesToDeleteInTable = $datesByMonth[$suffix];
// Build one statement to delete all dates from the given table
$sql = $bind = array();
$datesToDeleteInTable = array_unique($datesToDeleteInTable);
foreach ($datesToDeleteInTable as $dateToDelete) {
$sql[] = '(date1 <= ? AND ? <= date2)';
$bind[] = $dateToDelete;
$bind[] = $dateToDelete;
}
$sql = implode(" OR ", $sql);
$query = "DELETE FROM {$table} " . " WHERE ( {$sql} ) " . " AND idsite IN (" . $sqlIdSites . ")";
Piwik_Query($query, $bind);
// var_dump($query);var_dump($bind);
//.........这里部分代码省略.........