Exemple #1
0
 /**
  * Disconnects and destroys the database connection.
  *
  * For tests.
  */
 public static function destroyDatabaseObject()
 {
     DbHelper::disconnectDatabase();
     self::$connection = null;
 }
Exemple #2
0
 /**
  * Connects to the database.
  * 
  * Shouldn't be called directly, use {@link get()} instead.
  * 
  * @param array|null $dbInfos Connection parameters in an array. Defaults to the `[database]`
  *                            INI config section.
  */
 public static function createDatabaseObject($dbInfos = null)
 {
     $config = Config::getInstance();
     if (is_null($dbInfos)) {
         $dbInfos = $config->database;
     }
     /**
      * Triggered before a database connection is established.
      * 
      * This event can be used to change the settings used to establish a connection.
      * 
      * @param array *$dbInfos Reference to an array containing database connection info,
      *                        including:
      * 
      *                        - **host**: The host name or IP address to the MySQL database.
      *                        - **username**: The username to use when connecting to the
      *                                        database.
      *                        - **password**: The password to use when connecting to the
      *                                       database.
      *                        - **dbname**: The name of the Piwik MySQL database.
      *                        - **port**: The MySQL database port to use.
      *                        - **adapter**: either `'PDO_MYSQL'` or `'MYSQLI'`
      */
     Piwik::postEvent('Reporting.getDatabaseConfig', array(&$dbInfos));
     $dbInfos['profiler'] = $config->Debug['enable_sql_profiler'];
     $adapter = $dbInfos['adapter'];
     $db = @Adapter::factory($adapter, $dbInfos);
     self::$connection = $db;
 }