本文整理汇总了PHP中Piwik::truncateAllTables方法的典型用法代码示例。如果您正苦于以下问题:PHP Piwik::truncateAllTables方法的具体用法?PHP Piwik::truncateAllTables怎么用?PHP Piwik::truncateAllTables使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik
的用法示例。
在下文中一共展示了Piwik::truncateAllTables方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tearDown
public function tearDown()
{
parent::tearDown();
Piwik_DataTable_Manager::getInstance()->deleteAll();
Piwik_Option::getInstance()->clearCache();
Piwik_Common::deleteTrackerCache();
Piwik_Site::clearCache();
Piwik::truncateAllTables();
Piwik_TablePartitioning::$tablesAlreadyInstalled = null;
}
示例2: tearDown
public function tearDown()
{
Piwik::truncateAllTables();
}
示例3: restoreDbTables
/**
* Truncates all tables then inserts the data in $tables into each
* mapped table.
*
* @param array $tables Array mapping table names with arrays of row data.
*/
protected static function restoreDbTables($tables)
{
// truncate existing tables
Piwik::truncateAllTables();
// insert data
$existingTables = Piwik::getTablesInstalled();
foreach ($tables as $table => $rows) {
// create table if it's an archive table
if (strpos($table, 'archive_') !== false && !in_array($table, $existingTables)) {
$tableType = strpos($table, 'archive_numeric') !== false ? 'archive_numeric' : 'archive_blob';
$createSql = Piwik::getTableCreateSql($tableType);
$createSql = str_replace(Piwik_Common::prefixTable($tableType), $table, $createSql);
Piwik_Query($createSql);
}
if (empty($rows)) {
continue;
}
$rowsSql = array();
foreach ($rows as $row) {
$values = array();
foreach ($row as $name => $value) {
if (is_null($value)) {
$values[] = 'NULL';
} else {
if (is_numeric($value)) {
$values[] = $value;
} else {
if (!ctype_print($value)) {
$values[] = "x'" . bin2hex(substr($value, 1)) . "'";
} else {
$values[] = "'{$value}'";
}
}
}
}
$rowsSql[] = "(" . implode(',', $values) . ")";
}
$sql = "INSERT INTO {$table} VALUES " . implode(',', $rowsSql);
Piwik_Query($sql);
}
}
示例4: testPurgeDataDeleteLogsNoData
/**
* Test that purgeData works when there's no data.
*
* @group Plugins
* @group PrivacyManager
*/
public function testPurgeDataDeleteLogsNoData()
{
Piwik::truncateAllTables();
foreach (Piwik::getTablesArchivesInstalled() as $table) {
Piwik_Exec("DROP TABLE {$table}");
}
// get purge data prediction
$prediction = Piwik_PrivacyManager::getPurgeEstimate();
// perform checks on prediction
$expectedPrediction = array();
$this->assertEquals($expectedPrediction, $prediction);
// purge data
$this->_setTimeToRun();
$this->instance->deleteLogData();
$this->instance->deleteReportData();
// perform checks
$this->assertEquals(0, $this->_getTableCount('log_visit'));
$this->assertEquals(0, $this->_getTableCount('log_conversion'));
$this->assertEquals(0, $this->_getTableCount('log_link_visit_action'));
$this->assertEquals(0, $this->_getTableCount('log_conversion_item'));
$archiveTables = self::_getArchiveTableNames();
$this->assertFalse($this->_tableExists($archiveTables['numeric'][0]));
// January
$this->assertFalse($this->_tableExists($archiveTables['numeric'][1]));
// February
$this->assertFalse($this->_tableExists($archiveTables['blob'][0]));
// January
$this->assertFalse($this->_tableExists($archiveTables['blob'][1]));
// February
}