# doctrine/dbal

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/doctrine-dbal).**

9,699 stars · 1,375 forks · PHP · MIT

## Links

- GitHub: https://github.com/doctrine/dbal
- Homepage: https://www.doctrine-project.org/projects/dbal.html
- awesome-repositories: https://awesome-repositories.com/repository/doctrine-dbal.md

## Topics

`database` `ibm-db2` `mariadb` `mysql` `oracle` `postgresql` `sql-server` `sqlite`

## Description

This project is a SQL database abstraction layer that provides a consistent object-oriented interface for interacting with multiple relational database systems. It includes a driver wrapper to standardize connections and result sets, a fluent query builder for constructing portable SQL statements, and a type mapper for converting database-specific data types into native application types and vice versa.

The library enables programmatic schema management through a schema manager that can introspect database metadata, model structures as objects, and generate the SQL required to migrate between different schema versions. It also supports a middleware-based execution pipeline, allowing the interception of database operations for logging or profiling.

The system covers a broad range of database capabilities, including portable SQL generation for various dialects, transaction management with support for savepoints and isolation levels, and security primitives such as prepared statements and parameter binding to prevent SQL injection. It also provides utilities for result set normalization and CRUD operation helpers.

The project includes a command-line interface for executing raw SQL statements directly against database connections.

## Tags

### Data & Databases

- [Database Abstraction Layers](https://awesome-repositories.com/f/data-databases/database-abstraction-layers.md) — Provides a consistent object-oriented interface for interacting with multiple relational database systems via a unified abstraction layer.
- [Fluent Query Construction](https://awesome-repositories.com/f/data-databases/expression-based-data-querying/fluent-query-apis/sql-syntax-tree-construction/fluent-query-construction.md) — Provides a fluent query builder for programmatically constructing portable SQL statements using method chaining.
- [Bidirectional Type Mappers](https://awesome-repositories.com/f/data-databases/bidirectional-type-mappers.md) — Includes a type mapper for converting database-specific data types into native application types and vice versa.
- [Connection Establishment](https://awesome-repositories.com/f/data-databases/connection-establishment.md) — Establishes authenticated sessions with relational databases using configuration parameters or connection strings. ([source](https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html))
- [Data Type Mappings](https://awesome-repositories.com/f/data-databases/data-type-mappings.md) — Converts data types between a relational database and the application using built-in and user-defined mappings. ([source](https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/architecture.html))
- [Database Driver Abstractions](https://awesome-repositories.com/f/data-databases/database-driver-abstractions.md) — Implements a driver wrapper that standardizes connections and result sets across various relational database vendors.
- [Database Drivers](https://awesome-repositories.com/f/data-databases/database-drivers.md) — Implements custom adapters and middleware to connect applications to proprietary or specialized relational database APIs.
- [Database Object Abstractions](https://awesome-repositories.com/f/data-databases/database-object-abstractions.md) — Represents tables, columns, and indexes as structured objects to ensure consistent normalization and quoting. ([source](https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/object-names.html))
- [Database Agnostic Generators](https://awesome-repositories.com/f/data-databases/database-query-execution/query-generators/database-agnostic-generators.md) — Provides a mechanism to generate SQL that is compatible across different database vendors and versions. ([source](https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/platforms.html))
- [Schema Introspection](https://awesome-repositories.com/f/data-databases/database-schema-management/schema-introspection.md) — Retrieves detailed metadata about tables, columns, and indexes to create an in-memory representation of the schema. ([source](https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/schema-manager.html))
- [Database Schema Managers](https://awesome-repositories.com/f/data-databases/database-schema-managers.md) — Programmatically inspects, models, and modifies database structures like tables and indexes using an object-oriented approach.
- [Database Transaction Management](https://awesome-repositories.com/f/data-databases/database-transaction-management.md) — Controls groups of database operations as single units of work with support for savepoints and isolation levels.
- [Object Oriented Querying](https://awesome-repositories.com/f/data-databases/object-oriented-querying.md) — Offers a consistent object-oriented interface to interact with multiple relational database vendors. ([source](https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/introduction.html))
- [Prepared Statements](https://awesome-repositories.com/f/data-databases/prepared-statements.md) — Implements prepared statements using placeholders to ensure security against injection and enable statement reuse. ([source](https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/data-retrieval-and-manipulation.html))
- [SQL Placeholder Bindings](https://awesome-repositories.com/f/data-databases/query-translators/placeholder-rebinders/sql-placeholder-bindings.md) — Uses positional and named placeholders to separate SQL logic from input data and prevent injection attacks.
- [Relational Database Abstractions](https://awesome-repositories.com/f/data-databases/relational-database-abstractions.md) — Provides a consistent object-oriented interface to interact with multiple relational database systems regardless of vendor. ([source](https://cdn.jsdelivr.net/gh/doctrine/dbal@4.4.x/README.md))
- [Programmatic Schema Forge Tools](https://awesome-repositories.com/f/data-databases/schema-migration-utilities/data-only-migrations/drop-create-schema-migrations/programmatic-schema-forge-tools.md) — Provides a programmatic API to execute DDL statements and control database structure without writing raw SQL. ([source](https://cdn.jsdelivr.net/gh/doctrine/dbal@4.4.x/README.md))
- [SQL Dialect Adapters](https://awesome-repositories.com/f/data-databases/sql-dialect-adapters.md) — Adapts queries to ensure compatibility and feature support across different relational database platforms. ([source](https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/architecture.html))
- [Dialect-Specific SQL Generation](https://awesome-repositories.com/f/data-databases/sql-generators/dialect-specific-sql-generation.md) — Translates abstract query requests into dialect-specific SQL strings based on the connected database version.
- [SQL Query Builders](https://awesome-repositories.com/f/data-databases/sql-query-builders.md) — Ships a fluent query builder for programmatically constructing portable SQL statements across different dialects.
- [Portable SQL Generation](https://awesome-repositories.com/f/data-databases/sql-query-generation/portable-sql-generation.md) — Creates database-specific queries and schema definitions that work across different relational database engines and versions.
- [Database Wrappers](https://awesome-repositories.com/f/data-databases/sqlite-drivers/database-wrappers.md) — Implements a driver wrapper that standardizes connections and result sets across different relational database vendors.
- [Format Conversions](https://awesome-repositories.com/f/data-databases/structured-data-schemas/format-conversions.md) — Translates application objects into the specific string formats required by the underlying database platform. ([source](https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/data-retrieval-and-manipulation.html))
- [Common Table Expressions](https://awesome-repositories.com/f/data-databases/common-table-expressions.md) — Supports the creation of named temporary result sets using Common Table Expressions (CTEs) within queries. ([source](https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/query-builder.html))
- [Savepoints](https://awesome-repositories.com/f/data-databases/data-integration-synchronization/data-integration/database-integrations/atomic-transaction-execution/savepoints.md) — Emulates nested transactions by managing SQL savepoints to allow partial rollbacks within a single connection.
- [Application Type Mappings](https://awesome-repositories.com/f/data-databases/data-type-mappings/system-type-mappings/application-type-mappings.md) — Enables implementing custom conversion logic between application objects and database values via an extensible type system. ([source](https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/types.html))
- [Database Type Mappings](https://awesome-repositories.com/f/data-databases/database-management-systems/database-systems-management/schema-management-tools/database-type-mappings.md) — Allows overriding default vendor type mappings to control how database columns are interpreted by the application. ([source](https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/types.html))
- [Nested Transactions](https://awesome-repositories.com/f/data-databases/database-transactions/nested-transactions.md) — Emulates nested transactions using SQL savepoints to allow partial rollbacks within a single connection. ([source](https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/transactions.html))
- [Retriable Transactions](https://awesome-repositories.com/f/data-databases/database-transactions/retriable-transactions.md) — Identifies transient failures like deadlocks to trigger automatic retry logic for transactions. ([source](https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/transactions.html))
- [Autoincrement Implementations](https://awesome-repositories.com/f/data-databases/generated-columns/autoincrement-implementations.md) — Creates self-incrementing primary keys using identity columns to ensure consistent ID generation across platforms. ([source](https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/how-to/postgresql-identity-migration.html))
- [Indexes and Constraints](https://awesome-repositories.com/f/data-databases/indexes-and-constraints.md) — Creates and manages indexes and foreign key constraints across different database platforms. ([source](https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/explanation/implicit-indexes.html))
- [In-Memory Schema Representations](https://awesome-repositories.com/f/data-databases/object-data-modelers/schema-driven-object-modeling/in-memory-schema-representations.md) — Represents database structures as an object graph to calculate differences and generate migration SQL.
- [Query Expression Builders](https://awesome-repositories.com/f/data-databases/query-expression-builders.md) — Includes a dedicated expression builder for generating nested logic and comparison snippets for SQL filters. ([source](https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/query-builder.html))
- [Query Result Fetching](https://awesome-repositories.com/f/data-databases/query-result-fetching.md) — Allows retrieving query results as associative arrays, numeric arrays, or indexed key-value pairs. ([source](https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/data-retrieval-and-manipulation.html))
- [Array Placeholder Expansion](https://awesome-repositories.com/f/data-databases/query-translators/placeholder-rebinders/sql-placeholder-bindings/array-placeholder-expansion.md) — Rewrites SQL queries to flatten arrays into placeholder lists for use in IN expressions. ([source](https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/data-retrieval-and-manipulation.html))
- [Portable Snippets](https://awesome-repositories.com/f/data-databases/raw-sql-execution/parameterized-sql-snippets/portable-snippets.md) — Generates vendor-specific SQL snippets and function calls to ensure consistent execution across different engines. ([source](https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/portability.html))
- [SQL CRUD Operations](https://awesome-repositories.com/f/data-databases/relational-database-storage/sql-crud-operations.md) — Provides simplified CRUD operation helpers to insert, update, or delete rows using associative arrays. ([source](https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/data-retrieval-and-manipulation.html))
- [SQL Literal Escaping](https://awesome-repositories.com/f/data-databases/sql-utilities/sql-literal-escaping.md) — Quotes and escapes string values to ensure they are treated as literals within database statements. ([source](https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/security.html))
- [Transaction Demarcation & Isolation](https://awesome-repositories.com/f/data-databases/transaction-management/transaction-demarcation-isolation.md) — Provides manual transaction demarcation and the ability to configure isolation levels for units of work. ([source](https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/transactions.html))

### Part of an Awesome List

- [Schema and Migration Tools](https://awesome-repositories.com/f/awesome-lists/data/schema-and-migration-tools.md) — Analyzes differences between two schema representations and generates the SQL required to migrate between them. ([source](https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/schema-manager.html))

### Programming Languages & Runtimes

- [Type Mapping](https://awesome-repositories.com/f/programming-languages-runtimes/cross-language-data-mapping/type-mapping.md) — Provides a system for translating database-specific data types into native application types and vice versa.

### Security & Cryptography

- [SQL Injection Prevention](https://awesome-repositories.com/f/security-cryptography/sql-injection-prevention.md) — Implements security primitives using prepared statements and parameter binding to prevent SQL injection attacks.

### Software Engineering & Architecture

- [Database Type Converters](https://awesome-repositories.com/f/software-engineering-architecture/data-schema-validation/data-type-validation/value-type-conversions/database-type-converters.md) — Translates database-specific data types into native language types to ensure consistent data handling. ([source](https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/types.html))
- [Schema Modeling Objects](https://awesome-repositories.com/f/software-engineering-architecture/object-oriented-models/schema-modeling-objects.md) — Creates an object-oriented representation of tables, sequences, and indexes to generate platform-specific SQL. ([source](https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/schema-representation.html))
- [Middleware Pipelines](https://awesome-repositories.com/f/software-engineering-architecture/middleware-pipelines.md) — Includes a middleware-based execution pipeline for intercepting database operations for logging and profiling.
- [Database Operation Interceptors](https://awesome-repositories.com/f/software-engineering-architecture/request-interception-middleware/database-operation-interceptors.md) — Features a middleware-based execution pipeline to intercept database operations for logging and profiling. ([source](https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/architecture.html))
