Writing database drivers

Last updated on
20 November 2024

Drupal 7 will no longer be supported after January 5, 2025. Learn more and find resources for Drupal 7 sites

PDO

Drupal 7 uses PDO (Php Data Objects) to access databases. You can find more information here: https://www.drupal.org/node/549702

Allowing prefetch in a custom database driver

If you use a third-party database driver that makes use of the DatabaseStatementPrefetch class, you may need to allow-list the driver by adding it to a variable.

Drupal core's own database drivers (and the contrib sqlsrv driver) do not require additional configuration. The contrib Oracle driver is allow-listed by default.

Example for settings.php:

$conf['database_statement_prefetch_valid_db_drivers'] = array('mydbdriver');

In addition, if a 3rd party database driver uses the DatabaseStatementPrefetch class it must now include the source file directly (as opposed to relying on autoloading). Again Drupal core's own database drivers, and the contrib Oracle driver already do this.

Help improve this page

Page status: No known problems

You can: