本文整理汇总了PHP中Piwik_Common::cachedTablePrefix方法的典型用法代码示例。如果您正苦于以下问题:PHP Piwik_Common::cachedTablePrefix方法的具体用法?PHP Piwik_Common::cachedTablePrefix怎么用?PHP Piwik_Common::cachedTablePrefix使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik_Common
的用法示例。
在下文中一共展示了Piwik_Common::cachedTablePrefix方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prefixTable
/**
* Returns the table name prefixed by the table prefix.
* Works in both Tracker and UI mode.
*
* @param string $table The table name to prefix, ie "log_visit"
* @return string The table name prefixed, ie "piwik-production_log_visit"
*/
public static function prefixTable($table)
{
if (is_null(self::$cachedTablePrefix)) {
self::$cachedTablePrefix = Piwik_Config::getInstance()->database['tables_prefix'];
}
return self::$cachedTablePrefix . $table;
}
示例2: setUp
public function setUp()
{
$dumpPath = PIWIK_INCLUDE_PATH . '/tmp/logdump.sql.gz';
$deflatedDumpPath = PIWIK_INCLUDE_PATH . '/tmp/logdump.sql';
$bufferSize = 1024 * 1024;
// drop all tables
Piwik::dropTables();
// download data dump
$dump = fopen(self::$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) {
throw new Exception("Could not download sql dump!");
}
// unzip the dump
exec("gunzip -c \"" . $dumpPath . "\" > \"{$deflatedDumpPath}\"", $output, $return);
if ($return !== 0) {
throw new Exception("gunzip failed: " . implode("\n", $output));
}
// load the data into the correct database
$user = Piwik_Config::getInstance()->database['username'];
$password = Piwik_Config::getInstance()->database['password'];
$dbName = Piwik_Config::getInstance()->database['dbname'];
Piwik_Config::getInstance()->database['tables_prefix'] = 'piwik_';
Piwik_Common::$cachedTablePrefix = null;
exec("mysql -u \"{$user}\" \"--password={$password}\" {$dbName} < \"" . $deflatedDumpPath . "\" 2>&1", $output, $return);
if ($return !== 0) {
throw new Exception("Failed to load sql dump: " . implode("\n", $output));
}
// make sure archiving will be called
Piwik_ArchiveProcessing::setBrowserTriggerArchiving(true);
}
示例3: setUpBeforeClass
public static function setUpBeforeClass()
{
$dbName = false;
if (!empty($GLOBALS['PIWIK_BENCHMARK_DATABASE'])) {
$dbName = $GLOBALS['PIWIK_BENCHMARK_DATABASE'];
}
// connect to database
self::createTestConfig();
self::connectWithoutDatabase();
// create specified fixture (global var not set, use default no-data fixture (see end of this file))
if (empty($GLOBALS['PIWIK_BENCHMARK_FIXTURE'])) {
$fixtureName = 'Piwik_Test_Fixture_EmptyOneSite';
} else {
$fixtureName = 'Piwik_Test_Fixture_' . $GLOBALS['PIWIK_BENCHMARK_FIXTURE'];
}
self::$fixture = new $fixtureName();
// figure out if the desired fixture has already been setup, and if not empty the database
$installedFixture = false;
try {
if (isset(self::$fixture->tablesPrefix)) {
Piwik_Config::getInstance()->database['tables_prefix'] = self::$fixture->tablesPrefix;
Piwik_Common::$cachedTablePrefix = null;
}
Piwik_Query("USE " . $dbName);
$installedFixture = Piwik_GetOption('benchmark_fixture_name');
} catch (Exception $ex) {
// ignore
}
$createEmptyDatabase = $fixtureName != $installedFixture;
parent::setUpBeforeClass($dbName, $createEmptyDatabase, $createConfig = false);
// if we created an empty database, setup the fixture
if ($createEmptyDatabase) {
self::$fixture->setUp();
Piwik_SetOption('benchmark_fixture_name', $fixtureName);
}
}