本文整理汇总了PHP中Piwik\Db::dropAllTables方法的典型用法代码示例。如果您正苦于以下问题:PHP Db::dropAllTables方法的具体用法?PHP Db::dropAllTables怎么用?PHP Db::dropAllTables使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik\Db
的用法示例。
在下文中一共展示了Db::dropAllTables方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
public function setUp()
{
// drop all tables
Db::dropAllTables();
// download data dump if url supplied
if (is_file($this->dumpUrl)) {
$dumpPath = $this->dumpUrl;
} else {
$dumpPath = PIWIK_INCLUDE_PATH . '/tmp/logdump.sql.gz';
$bufferSize = 1024 * 1024;
$dump = fopen($this->dumpUrl, 'rb');
$outfile = fopen($dumpPath, 'wb');
$bytesRead = 0;
while (!feof($dump)) {
fwrite($outfile, fread($dump, $bufferSize), $bufferSize);
$bytesRead += $bufferSize;
}
fclose($dump);
fclose($outfile);
if ($bytesRead <= 40 * 1024 * 1024) {
// sanity check
throw new Exception("Could not download sql dump!");
}
}
// unzip the dump
if (substr($dumpPath, -3) === ".gz") {
$deflatedDumpPath = PIWIK_INCLUDE_PATH . '/tmp/logdump.sql';
// TODO: should depend on name of URL
exec("gunzip -c \"" . $dumpPath . "\" > \"{$deflatedDumpPath}\"", $output, $return);
if ($return !== 0) {
throw new Exception("gunzip failed: " . implode("\n", $output));
}
} else {
$deflatedDumpPath = $dumpPath;
}
// load the data into the correct database
$user = Config::getInstance()->database['username'];
$password = Config::getInstance()->database['password'];
Config::getInstance()->database['tables_prefix'] = $this->tablesPrefix;
$cmd = "mysql -u \"{$user}\" \"--password={$password}\" {$this->dbName} < \"" . $deflatedDumpPath . "\" 2>&1";
exec($cmd, $output, $return);
if ($return !== 0) {
throw new Exception("Failed to load sql dump: " . implode("\n", $output));
}
// make sure archiving will be called
Rules::setBrowserTriggerArchiving(true);
// reload access
Piwik::setUserHasSuperUserAccess();
$this->getTestEnvironment()->configOverride = array('database' => array('tables_prefix' => $this->tablesPrefix));
$this->getTestEnvironment()->save();
}
示例2: setUp
public function setUp()
{
// drop all tables
Db::dropAllTables();
// download data dump if url supplied
if (is_file($this->dumpUrl)) {
$dumpPath = $this->dumpUrl;
} else {
$dumpPath = PIWIK_INCLUDE_PATH . '/tmp/logdump.sql.gz';
$bytesRead = $this->downloadDumpInPath($dumpPath);
// sanity check
if ($bytesRead <= 40 * 1024 * 1024) {
$str = "Could not download sql dump! You can manually download %s into %s";
throw new Exception(sprintf($str, $this->dumpUrl, $dumpPath));
}
}
// unzip the dump
if (substr($dumpPath, -3) === ".gz") {
$deflatedDumpPath = PIWIK_INCLUDE_PATH . '/tmp/logdump.sql';
// TODO: should depend on name of URL
exec("gunzip -c \"" . $dumpPath . "\" > \"{$deflatedDumpPath}\"", $output, $return);
if ($return !== 0) {
throw new Exception("gunzip failed: " . implode("\n", $output));
}
} else {
$deflatedDumpPath = $dumpPath;
}
// load the data into the correct database
$user = Config::getInstance()->database['username'];
$password = Config::getInstance()->database['password'];
$host = Config::getInstance()->database['host'];
Config::getInstance()->database['tables_prefix'] = $this->tablesPrefix;
$cmd = "mysql -h \"{$host}\" -u \"{$user}\" \"--password={$password}\" {$this->dbName} < \"" . $deflatedDumpPath . "\" 2>&1";
exec($cmd, $output, $return);
if ($return !== 0) {
throw new Exception("Failed to load sql dump: " . implode("\n", $output));
}
// make sure archiving will be called
Rules::setBrowserTriggerArchiving(true);
// reload access
Access::getInstance()->reloadAccess();
$testVars = new TestingEnvironmentVariables();
$testVars->configOverride = array('database' => array('tables_prefix' => $this->tablesPrefix));
$testVars->save();
}
示例3: tablesCreation
/**
* Installation Step 4: Table Creation
*/
function tablesCreation()
{
$this->checkPiwikIsNotInstalled();
$view = new View('@Installation/tablesCreation', $this->getInstallationSteps(), __FUNCTION__);
if ($this->getParam('deleteTables')) {
Manager::getInstance()->clearPluginsInstalledConfig();
Db::dropAllTables();
$view->existingTablesDeleted = true;
}
$tablesInstalled = DbHelper::getTablesInstalled();
$view->tablesInstalled = '';
if (count($tablesInstalled) > 0) {
// we have existing tables
$view->tablesInstalled = implode(', ', $tablesInstalled);
$view->someTablesInstalled = true;
Access::getInstance();
Piwik::setUserHasSuperUserAccess();
if ($this->hasEnoughTablesToReuseDb($tablesInstalled) && count(APISitesManager::getInstance()->getAllSitesId()) > 0 && count(APIUsersManager::getInstance()->getUsers()) > 0) {
$view->showReuseExistingTables = true;
}
} else {
DbHelper::createTables();
DbHelper::createAnonymousUser();
$this->updateComponents();
Updater::recordComponentSuccessfullyUpdated('core', Version::VERSION);
$view->tablesCreated = true;
$view->showNextStep = true;
}
return $view->render();
}