mondrake/drudbal

Drupal driver for Doctrine DBAL.

Installs: 2 765

Dependents: 0

Suggesters: 0

Security: 0

Stars: 8

Watchers: 3

Forks: 1

Open Issues: 2

Type:drupal-module

dev-master 2024-06-01 16:34 UTC

This package is auto-updated.

Last update: 2024-10-31 00:17:10 UTC


README

MySql via PDO MySql via mysqli SQLite via PDO Oracle via oci8 PHPStan level License

(This README updated March 30, 2020)

An experimental Drupal database driver for Doctrine DBAL. Do not use if not for trial. No support, sorry :)

Concept

The concept is to use Doctrine DBAL as an additional database abstraction layer. The code of the DBAL Drupal database driver is meant to be 'database agnostic', i.e. the driver should be able to execute on any db platform that DBAL supports (in theory, practically there still need to be db-platform specific hacks through the concept of DBAL extensions, see below).

The Drupal database Connection class that this driver implements opens a DBAL\Connection, and hands over statements' execution to it. DBAL\Connection itself wraps a lower level driver connection (PDO for pdo_mysql and pdo_sqlite drivers, mysqli for the mysqli driver). Similarly, the StatementWrapper wraps a DBAL\Statement, which itself wraps a DBAL-driver level Statement. The DBAL connection provides additional features like the Schema Manager that can introspect a database schema and build DDL statements, a Query Builder that can build SQL statements based on the database platform in use, etc. etc.

To overcome DBAL limitations and/or fit Drupal specifics, the DBAL Drupal database driver also instantiates an additional object called DBALExtension, unique for the DBAL Driver in use, to which some operations that are db- or Drupal-specific are delegated.

Status

The code in the master branch is working on a MySql database, using either the 'mysql' or the 'mysqli' DBAL drivers, on a SQlite database, using the 'sqlite' DBAL driver, or on a Oracle database using the 'oci8' database driver.

'Working' means:

  1. it is possible to install a Drupal site via the installer, selecting 'Doctrine DBAL' as the database of choice;
  2. it is passing a selection of core PHPUnit tests , executed on GitHub Actions CI. The latest patches for the issues listed in 'Related Drupal issues' below need to be applied to get a clean test run.

Installation

Very rough instructions to install Drupal from scratch with this db driver under the hood:

  1. Get the DruDbal module from Packagist via Composer, it will install Doctrine DBAL as well:
$ composer require mondrake/drudbal:dev-master
  1. Launch the interactive installer. Proceed as usual and when on the db selection form, select 'Doctrine DBAL' and enter a 'database URL' compliant with Doctrine DBAL syntax. Note: the driver works only with mysql, mysqli, oci8 or sqlite DBAL drivers.

configuration

  1. If everything goes right, when you're welcomed to the new Drupal installation, visit the Status Report. The 'database' section will report something like:

status_report

Related DBAL issues/PRs

Related Drupal issues