The Game Panel Design record
The Game Panel
ADR-0008 Accepted

Database Build database access is built directly on PDO

Comparing
v1 to v2
Current
Read the document

Context

The panel needs database access: connectionsconnections, a way to build queries, and a way to build build and change the schema. . Existing database abstraction layers provide all of that, but each one pulls in brings a great deal of of code and a large large number of third-party librarieslibraries with it, which adds to the panel's footprint and complicates it.

Decision

The I will build the database component is built directly on PHP's PDO extension, with its own connectionsown connections, query builder and schema schema builder, rather than on an existing database database abstraction layer.

Alternatives

An existing database abstraction layer. Every , providing connections, query building and schema building ready-made. I rejected this because every one available pulls in so much code and so many third-party party libraries that it it complicates the panel and adds to its footprint.

No other alternatives were weighed.

Consequences

Easier:

  • The panel's footprint stays will stay small. The database component needs will need the PDO extension and no further further libraries.
  • The component's API follows will follow the panel's own conventions, such as configuration held in typed objects and connections connections injected through an attribute.

Harder:

  • The component owns will own everything a database abstraction layer would otherwise provide, and its correctness: connection handling, differences between drivers, SQL generation, identifier quoting and bindingsand bound values.

Constrained:

  • Supporting another database means will mean writing that support inside the component, as the hidden driver support in ADR-0007 anticipates.

Sources

  • Commit 4e4b8bf, "Create connection factory", , on the branch of PR #30: the first code creating connections directly with PDO, which is created.
  • PR #30, feat(database): Add the database component, merged and squashed as 560e9ab: the component built on PDO, which is decided.
  • composer.json at 560e9ab: the PDO extension required, and no database abstraction layer.
  • The decision and its reason, that existing database abstraction layers pull in so much code and so many third-party libraries that they complicate the panel and add to its footprint: first written down on , with no record of when they were weighed.
  • Issues #41, #42 and #48, and : defects in identifier quoting, bindings and connection options, which show the correctness the component owns, taken from what followed rather than anticipated.

Source adr/0008-direct-pdo.md · commit 9444a99 · published