SADB

Component ID

2795593

Component name

SADB

Component type

module

Maintenance status

Development status

Component security advisory coverage

not-covered

Downloads

139

Component created

Component changed

Component body

Description

SADB is a StandAlone DataBase connection helper, allow modules to connect to the databases other than mentioned in the settings.php.

Usage 1

Connect to a user entered database.

Usage 2

Create and use a sqlite database for each user, each node ...

Example 1 : Minimum for SQLite DB connection.

use DrupalsadbDatabaseDatabaseSA;
    $settings = array(
      'database' => 'public://.ht.test.sqlite',
      'driver' => 'sqlite',
    );
    $con = (new DatabaseSA($settings))->getConnection();

Example 2 : Minimum for MySQL DB connection.

use DrupalsadbDatabaseDatabaseSA;
    $settings = array(
      'database' => 'my_other_db',
      'username' => 'root',
      'driver' => 'mysql',
    );
    $con = (new DatabaseSA($settings))->getConnection();

Example 3 : Another MySQL DB connection.

use DrupalsadbDatabaseDatabaseSA;
    $settings = array(
      'database' => 'my_other_db',
      'username' => 'root',
      'password' => 'thepassword',
      'prefix' => 'mytabs_',
      'host' => '127.0.0.1',
      'port' => '33066',
      'namespace' => 'Drupal\Core\Database\Driver\mysql',
      'driver' => 'mysql',
    );
    $con = (new DatabaseSA($settings))->getConnection();