# falseclock/dbd-php architecture

> Architecture diagram of the GitHub repository falseclock/dbd-php, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/falseclock/dbd-php
- Repository: https://github.com/falseclock/dbd-php

## Overview

DBD-PHP is a PHP database-driver library whose main workflow is configuring a driver, preparing or executing SQL with bound parameters, and fetching results. The shared DBD runtime also provides CRUD/entity helpers, transactions, caching, and debugging; PostgreSQL is the documented ready driver, alongside MySQL and MSSQL implementations. A separate OData driver handles HTTP-backed entity operations and metadata, with YellowERP as a related integration. Edges follow the README and source-index references; unsampled driver internals and runtime dispatch are not inferred.

Main entry points: [`src/DBD.php`](https://github.com/falseclock/dbd-php/blob/master/src/DBD.php) (DBD runtime), [`src/Pg.php`](https://github.com/falseclock/dbd-php/blob/master/src/Pg.php) (PostgreSQL driver), [`src/OData.php`](https://github.com/falseclock/dbd-php/blob/master/src/OData.php) (OData driver), [`src/Common/Bind.php`](https://github.com/falseclock/dbd-php/blob/master/src/Common/Bind.php) (Typed parameters)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Database runtime"]
  node_dbd["DBD runtime<br/>[DBD.php]"]
end

subgraph group_support["Shared services"]
  node_config["Connection config<br/>[Config.php]"]
  node_options["Driver options<br/>[Options.php]"]
  node_bind["Typed parameters<br/>[Bind.php]"]
  node_query["Query context<br/>[Query.php]"]
  node_helper["SQL helpers<br/>[Helper.php]"]
  node_insertargs["Insert arguments"]
  node_updateargs["Update arguments"]
  node_cache["Cache integration<br/>[Cache.php]"]
  node_memcache["MemCache adapter<br/>[MemCache.php]"]
  node_debug["Query debugging<br/>[Debug.php]"]
  node_errors["Database errors<br/>[DBDException.php]"]
  node_crud["CRUD definitions<br/>[CRUD.php]"]
end

subgraph group_odata["OData integration"]
  node_odata["OData driver<br/>[OData.php]"]
  node_metadata["Metadata model<br/>[Metadata.php]"]
  node_entitytype["Entity type<br/>[EntityType.php]"]
  node_yellowerp["YellowERP integration<br/>[YellowERP.php]"]
end

subgraph group_drivers["Database drivers"]
  node_pg["PostgreSQL driver<br/>[Pg.php]"]
  node_mysql["MySQL driver<br/>[MySQL.php]"]
  node_mssql["MSSQL driver<br/>[MSSQL.php]"]
end

node_consumer(("PHP application"))
node_database[("Database server")]

node_consumer -->|"configures and connects"| node_pg
node_consumer -->|"executes and fetches"| node_dbd
node_dbd -->|"uses configuration"| node_config
node_dbd -->|"uses options"| node_options
node_dbd -->|"creates binds"| node_bind
node_dbd -->|"prepares arguments"| node_helper
node_dbd -->|"uses cache"| node_cache
node_dbd -->|"records query context"| node_query
node_dbd -->|"measures queries"| node_debug
node_dbd -->|"raises errors"| node_errors
node_dbd -->|"uses CRUD rules"| node_crud
node_dbd -->|"builds insert arguments"| node_insertargs
node_dbd -->|"builds update arguments"| node_updateargs
node_pg -->|"uses typed binds"| node_bind
node_pg -->|"reads configuration"| node_config
node_pg -->|"reads options"| node_options
node_pg -.->|"executes SQL"| node_database
node_mysql -->|"uses typed binds"| node_bind
node_mssql -->|"uses typed binds"| node_bind
node_cache -->|"supports adapter"| node_memcache
node_helper -->|"returns arguments"| node_insertargs
node_helper -->|"returns arguments"| node_updateargs
node_helper -->|"validates query type"| node_crud
node_odata -->|"reads configuration"| node_config
node_odata -->|"uses typed binds"| node_bind
node_odata -->|"uses CRUD rules"| node_crud
node_odata -->|"parses metadata"| node_metadata
node_metadata -->|"models entity types"| node_entitytype
node_yellowerp -->|"uses OData driver"| node_odata

click node_dbd "https://github.com/falseclock/dbd-php/blob/master/src/DBD.php"
click node_pg "https://github.com/falseclock/dbd-php/blob/master/src/Pg.php"
click node_mysql "https://github.com/falseclock/dbd-php/blob/master/src/MySQL.php"
click node_mssql "https://github.com/falseclock/dbd-php/blob/master/src/MSSQL.php"
click node_config "https://github.com/falseclock/dbd-php/blob/master/src/Common/Config.php"
click node_options "https://github.com/falseclock/dbd-php/blob/master/src/Common/Options.php"
click node_bind "https://github.com/falseclock/dbd-php/blob/master/src/Common/Bind.php"
click node_query "https://github.com/falseclock/dbd-php/blob/master/src/Common/Query.php"
click node_helper "https://github.com/falseclock/dbd-php/blob/master/src/Helpers/Helper.php"
click node_insertargs "https://github.com/falseclock/dbd-php/blob/master/src/Helpers/InsertArguments.php"
click node_updateargs "https://github.com/falseclock/dbd-php/blob/master/src/Helpers/UpdateArguments.php"
click node_cache "https://github.com/falseclock/dbd-php/blob/master/src/Cache.php"
click node_memcache "https://github.com/falseclock/dbd-php/blob/master/src/Cache/MemCache.php"
click node_debug "https://github.com/falseclock/dbd-php/blob/master/src/Common/Debug.php"
click node_errors "https://github.com/falseclock/dbd-php/blob/master/src/Common/DBDException.php"
click node_crud "https://github.com/falseclock/dbd-php/blob/master/src/Common/CRUD.php"
click node_odata "https://github.com/falseclock/dbd-php/blob/master/src/OData.php"
click node_metadata "https://github.com/falseclock/dbd-php/blob/master/src/Helpers/OData/Metadata.php"
click node_entitytype "https://github.com/falseclock/dbd-php/blob/master/src/Helpers/OData/EntityType.php"
click node_yellowerp "https://github.com/falseclock/dbd-php/blob/master/src/YellowERP.php"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_dbd toneBlue
class node_config,node_options,node_bind,node_query,node_helper,node_insertargs,node_updateargs,node_cache,node_memcache,node_debug,node_errors,node_crud,node_database toneAmber
class node_odata,node_metadata,node_entitytype,node_yellowerp toneMint
class node_pg,node_mysql,node_mssql toneRose
class node_consumer toneIndigo
```

## Components

### Database runtime

- [DBD runtime](https://github.com/falseclock/dbd-php/blob/master/src/DBD.php): `src/DBD.php`

### Shared services

- [Connection config](https://github.com/falseclock/dbd-php/blob/master/src/Common/Config.php): `src/Common/Config.php`
- [Driver options](https://github.com/falseclock/dbd-php/blob/master/src/Common/Options.php): `src/Common/Options.php`
- [Typed parameters](https://github.com/falseclock/dbd-php/blob/master/src/Common/Bind.php): `src/Common/Bind.php`
- [Query context](https://github.com/falseclock/dbd-php/blob/master/src/Common/Query.php): `src/Common/Query.php`
- [SQL helpers](https://github.com/falseclock/dbd-php/blob/master/src/Helpers/Helper.php): `src/Helpers/Helper.php`
- [Insert arguments](https://github.com/falseclock/dbd-php/blob/master/src/Helpers/InsertArguments.php): `src/Helpers/InsertArguments.php`
- [Update arguments](https://github.com/falseclock/dbd-php/blob/master/src/Helpers/UpdateArguments.php): `src/Helpers/UpdateArguments.php`
- [Cache integration](https://github.com/falseclock/dbd-php/blob/master/src/Cache.php): `src/Cache.php`
- [MemCache adapter](https://github.com/falseclock/dbd-php/blob/master/src/Cache/MemCache.php): `src/Cache/MemCache.php`
- [Query debugging](https://github.com/falseclock/dbd-php/blob/master/src/Common/Debug.php): `src/Common/Debug.php`
- [Database errors](https://github.com/falseclock/dbd-php/blob/master/src/Common/DBDException.php): `src/Common/DBDException.php`
- [CRUD definitions](https://github.com/falseclock/dbd-php/blob/master/src/Common/CRUD.php): `src/Common/CRUD.php`

### OData integration

- [OData driver](https://github.com/falseclock/dbd-php/blob/master/src/OData.php): `src/OData.php`
- [Metadata model](https://github.com/falseclock/dbd-php/blob/master/src/Helpers/OData/Metadata.php): `src/Helpers/OData/Metadata.php`
- [Entity type](https://github.com/falseclock/dbd-php/blob/master/src/Helpers/OData/EntityType.php): `src/Helpers/OData/EntityType.php`
- [YellowERP integration](https://github.com/falseclock/dbd-php/blob/master/src/YellowERP.php): `src/YellowERP.php`

### Database drivers

- [PostgreSQL driver](https://github.com/falseclock/dbd-php/blob/master/src/Pg.php): `src/Pg.php`
- [MySQL driver](https://github.com/falseclock/dbd-php/blob/master/src/MySQL.php): `src/MySQL.php`
- [MSSQL driver](https://github.com/falseclock/dbd-php/blob/master/src/MSSQL.php): `src/MSSQL.php`

### Other components

- **PHP application**
- **Database server**

## Connections

- PHP application → PostgreSQL driver: configures and connects (evidence: `README.md`)
- PHP application → DBD runtime: executes and fetches (evidence: `README.md`)
- DBD runtime → Connection config: uses configuration (evidence: `src/DBD.php`)
- DBD runtime → Driver options: uses options (evidence: `src/DBD.php`)
- DBD runtime → Typed parameters: creates binds (evidence: `src/DBD.php`)
- DBD runtime → SQL helpers: prepares arguments (evidence: `src/DBD.php`)
- DBD runtime → Cache integration: uses cache (evidence: `src/DBD.php`)
- DBD runtime → Query context: records query context (evidence: `src/Common/Query.php`)
- DBD runtime → Query debugging: measures queries (evidence: `src/DBD.php`)
- DBD runtime → Database errors: raises errors (evidence: `src/DBD.php`)
- DBD runtime → CRUD definitions: uses CRUD rules (evidence: `src/DBD.php`)
- DBD runtime → Insert arguments: builds insert arguments (evidence: `src/DBD.php`)
- DBD runtime → Update arguments: builds update arguments (evidence: `src/DBD.php`)
- PostgreSQL driver → Typed parameters: uses typed binds (evidence: `src/Pg.php`)
- PostgreSQL driver → Connection config: reads configuration (evidence: `src/Pg.php`)
- PostgreSQL driver → Driver options: reads options (evidence: `src/Pg.php`)
- PostgreSQL driver → Database server: executes SQL
- MySQL driver → Typed parameters: uses typed binds (evidence: `src/MySQL.php`)
- MSSQL driver → Typed parameters: uses typed binds (evidence: `src/MSSQL.php`)
- Cache integration → MemCache adapter: supports adapter (evidence: `src/Cache/MemCache.php`)
- SQL helpers → Insert arguments: returns arguments (evidence: `src/Helpers/Helper.php`)
- SQL helpers → Update arguments: returns arguments (evidence: `src/Helpers/Helper.php`)
- SQL helpers → CRUD definitions: validates query type (evidence: `src/Helpers/Helper.php`)
- OData driver → Connection config: reads configuration (evidence: `src/OData.php`)
- OData driver → Typed parameters: uses typed binds (evidence: `src/OData.php`)
- OData driver → CRUD definitions: uses CRUD rules (evidence: `src/OData.php`)
- OData driver → Metadata model: parses metadata (evidence: `src/OData.php`)
- Metadata model → Entity type: models entity types (evidence: `src/Helpers/OData/Metadata.php`)
- YellowERP integration → OData driver: uses OData driver (evidence: `src/YellowERP.php`)
