1.20.x config_database_storage.inc public ConfigDatabaseStorage::__construct($dburl)

Constructs a new ConfigDatabaseStorage controller.

Parameters

string $dburl: A URL that references a backdrop connection (optional) and table. The string has a format of db:/<database connection>/<database table>. If no database connection is specified, then the 'default' connection is used.

Examples:

  • db:/default/config_active
  • db:config_active
  • db://config_active
  • db:/config_store/config_stage

File

drivers/config_database/config_database_storage.inc, line 87

Class

ConfigDatabaseStorage
Defines the database storage controller.

Code

public function __construct($dburl) {
  $matches = array();
  preg_match('/^db:(\/(\w*)\/)?(\w+)$/', trim($dburl), $matches);
  if (count($matches) != 4) {
    throw new ConfigStorageException(t('Invalid database specifier: @db', array('@db' => $dburl)));
  }
  $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';
  }
}