本文整理匯總了PHP中Piwik\Db::getDatabaseConfig方法的典型用法代碼示例。如果您正苦於以下問題:PHP Db::getDatabaseConfig方法的具體用法?PHP Db::getDatabaseConfig怎麽用?PHP Db::getDatabaseConfig使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Piwik\Db
的用法示例。
在下文中一共展示了Db::getDatabaseConfig方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: connect
/**
* Connects to the DB
*
* @throws Exception if there was an error connecting the DB
*/
public function connect()
{
if (self::$profiling) {
$timer = $this->initProfiler();
}
$config = PiwikDb::getDatabaseConfig();
$this->connection = @new PDO($this->dsn, $this->username, $this->password, $config['driver_options']);
$this->connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// we may want to setAttribute(PDO::ATTR_TIMEOUT ) to a few seconds (default is 60) in case the DB is locked
// the piwik.php would stay waiting for the database... bad!
// we delete the password from this object "just in case" it could be printed
$this->password = '';
/*
* Lazy initialization via MYSQL_ATTR_INIT_COMMAND depends
* on mysqlnd support, PHP version, and OS.
* see ZF-7428 and http://bugs.php.net/bug.php?id=47224
*/
if (!empty($this->charset)) {
$sql = "SET NAMES '" . $this->charset . "'";
$this->connection->exec($sql);
}
if (self::$profiling && isset($timer)) {
$this->recordQueryProfile('connect', $timer);
}
}
示例2: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
// Set memory limit to off
@ini_set('memory_limit', -1);
Piwik::doAsSuperUser(function () use($input, $output) {
$settings = new MigratorSettings();
$settings->idSite = $input->getArgument('idSite');
$settings->site = $this->getSite($settings->idSite);
$settings->dateFrom = $input->getOption('date-from') ? new \DateTime($input->getOption('date-from')) : null;
$settings->dateTo = $input->getOption('date-to') ? new \DateTime($input->getOption('date-to')) : null;
$settings->skipArchiveData = $input->getOption('skip-archive-data');
$settings->skipLogData = $input->getOption('skip-log-data');
$config = Db::getDatabaseConfig();
$startTime = microtime(true);
$this->createTargetDatabaseConfig($input, $output, $config);
$tmpConfig = $config;
$sourceDb = Db::get();
try {
$targetDb = @Db\Adapter::factory($config['adapter'], $tmpConfig);
} catch (\Exception $e) {
throw new \RuntimeException('Unable to connect to the target database: ' . $e->getMessage(), 0, $e);
}
$sourceDbHelper = new DBHelper($sourceDb, Db::getDatabaseConfig());
$migratorFacade = new Migrator($sourceDbHelper, new DBHelper($targetDb, $config), GCHelper::getInstance(), $settings, new ArchiveLister($sourceDbHelper));
$migratorFacade->migrate();
$endTime = microtime(true);
Log::debug(sprintf('Time taken: %01.2f sec', $endTime - $startTime));
Log::debug(sprintf('Peak memory usage: %01.2f MB', memory_get_peak_usage(true) / 1048576));
});
}
示例3: getDbName
private function getDbName()
{
$dbInfos = Db::getDatabaseConfig();
$dbName = $dbInfos['dbname'];
return $dbName;
}
示例4: getDbSetting
private function getDbSetting($key)
{
$dbInfos = Db::getDatabaseConfig();
$engine = $dbInfos[$key];
return $engine;
}