Database API

Drupal's database abstraction layer provides a unified database query API that can query different underlying databases. It is built upon PHP's PDO (PHP Data Objects) database API, and inherits much of its syntax and semantics.

Besides providing a unified API for database queries, the database abstraction layer also provides a structured way to construct complex queries, and it protects the database by using good security practices.

Database API Overview

Documentation for Database API in Drupal 8.

General concepts

General concepts (stub page)

Database Configuration

Database Configuration

Instantiating a Connection Object

Instantiating a Connection Object

Static Queries

Static Queries

Dynamic Queries

Dynamic queries in Drupal 8 Database API.

Result Sets

Result Sets

Fetching Into a Custom Class

Fetching Into a Custom Class

Insert Queries

Insert Queries

Update Queries

Update Queries

Merge Queries

Merge Queries

Delete Queries

Delete Queries

Transactions

Transactions

Error Handling

Error Handling

Functions and Operators

Functions and Operators

Tags

Guide maintainers