当前位置: 首页>>代码示例>>PHP>>正文


PHP Db::getDatabaseConfig方法代码示例

本文整理汇总了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);
     }
 }
开发者ID:igorclark,项目名称:piwik,代码行数:30,代码来源:Mysql.php

示例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));
     });
 }
开发者ID:saadouus,项目名称:plugin-SiteMigration,代码行数:30,代码来源:MigrateSite.php

示例3: getDbName

 private function getDbName()
 {
     $dbInfos = Db::getDatabaseConfig();
     $dbName = $dbInfos['dbname'];
     return $dbName;
 }
开发者ID:josl,项目名称:CGE-File-Sharing,代码行数:6,代码来源:Mysql.php

示例4: getDbSetting

 private function getDbSetting($key)
 {
     $dbInfos = Db::getDatabaseConfig();
     $engine = $dbInfos[$key];
     return $engine;
 }
开发者ID:bossrabbit,项目名称:piwik,代码行数:6,代码来源:Settings.php


注:本文中的Piwik\Db::getDatabaseConfig方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。