1 config.inc public ConfigDatabaseStorage::__construct($db_url)

Constructs a new ConfigDatabaseStorage controller.

Parameters

string $db_url: A URL that references a backdrop connection (optional) and table. The string has a format of db://<database connection>/<database table>.

Examples:

  • db://default/config_active
  • db://second_database/config_staging

Throws

ConfigStorageException

File

core/includes/config.inc, line 1324
This is the API for configuration storage.

Class

ConfigDatabaseStorage
Defines the database storage controller.

Code

public function __construct($db_url) {
  $matches = array();
  preg_match('/^db:(\/\/(\w*)\/)?(\w+)$/', trim($db_url), $matches);
  if (count($matches) != 4) {
    throw new ConfigStorageException(t('Invalid database specifier: @db', array('@db' => $db_url)));
  }
  $this->table = $matches[3];
  $this->database = $matches[2] ? $matches[2] : 'default';

  // Bootstrap the database if it is not yet available.
  if (!function_exists('db_query') || backdrop_get_bootstrap_phase() < BACKDROP_BOOTSTRAP_DATABASE) {
    require_once BACKDROP_ROOT . '/core/includes/database/database.inc';
    backdrop_bootstrap(BACKDROP_BOOTSTRAP_DATABASE, FALSE);
  }
}