function Connection::createUrlFromConnectionOptions

Same name in this branch
  1. 11.x core/lib/Drupal/Core/Database/Connection.php \Drupal\Core\Database\Connection::createUrlFromConnectionOptions()
Same name in other branches
  1. 9 core/modules/sqlite/src/Driver/Database/sqlite/Connection.php \Drupal\sqlite\Driver\Database\sqlite\Connection::createUrlFromConnectionOptions()
  2. 9 core/lib/Drupal/Core/Database/Connection.php \Drupal\Core\Database\Connection::createUrlFromConnectionOptions()
  3. 8.9.x core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php \Drupal\Core\Database\Driver\sqlite\Connection::createUrlFromConnectionOptions()
  4. 8.9.x core/lib/Drupal/Core/Database/Connection.php \Drupal\Core\Database\Connection::createUrlFromConnectionOptions()
  5. 10 core/modules/sqlite/src/Driver/Database/sqlite/Connection.php \Drupal\sqlite\Driver\Database\sqlite\Connection::createUrlFromConnectionOptions()
  6. 10 core/lib/Drupal/Core/Database/Connection.php \Drupal\Core\Database\Connection::createUrlFromConnectionOptions()

Overrides Connection::createUrlFromConnectionOptions

File

core/modules/sqlite/src/Driver/Database/sqlite/Connection.php, line 456

Class

Connection
SQLite implementation of \Drupal\Core\Database\Connection.

Namespace

Drupal\sqlite\Driver\Database\sqlite

Code

public static function createUrlFromConnectionOptions(array $connection_options) {
    if (!isset($connection_options['driver'], $connection_options['database'])) {
        throw new \InvalidArgumentException("As a minimum, the connection options array must contain at least the 'driver' and 'database' keys");
    }
    $db_url = 'sqlite://localhost/' . $connection_options['database'] . '?module=sqlite';
    if (isset($connection_options['prefix']) && $connection_options['prefix'] !== '') {
        $db_url .= '#' . $connection_options['prefix'];
    }
    return $db_url;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.