Skip to content

PDO database strategy — maintained replacement for SafeMySQL - #16

Merged
alexstandiford merged 3 commits into
mainfrom
feat/pdo-database-strategy
Jun 12, 2026
Merged

PDO database strategy — maintained replacement for SafeMySQL#16
alexstandiford merged 3 commits into
mainfrom
feat/pdo-database-strategy

Conversation

@alexstandiford

Copy link
Copy Markdown
Contributor

Implements the replacement path from phpnomad/safemysql-integration#2: PdoConnection + PdoDatabaseStrategy + PdoAtomicOperationStrategy with the full SafeMySQL placeholder language (driver-delegated escaping), behavior-parity preprocessing, stable error messages, and real-MySQL tests (CI gains a mysql service). Consumers swap bindings and drop colshrapnel/safemysql entirely.

Adds PdoConnection (lazy PDO from the same host/user/pass/db/port/charset
config shape SafeMySQL consumers already pass, or fromPdo() for an
existing handle), PdoDatabaseStrategy, and PdoAtomicOperationStrategy.

PdoDatabaseStrategy::parse() implements the placeholder language the
query builders emit — ?n identifier, ?s string, ?i integer, ?a IN-list,
?u SET clause, ?p raw — with value escaping delegated to PDO::quote().
The SafeMySQL integration's argument preprocessing (row-array lists and
associative arrays arriving at ?a/?p become raw VALUES tuples; scalars
at ?a are wrapped) is preserved placeholder-aware, which also makes ?u
actually usable with associative arrays (it was clobbered by the blanket
preprocessing before). query() keeps the contract: result sets return
associative rows, writes return the affected-row count, and failures
throw a stable non-leaking message with the driver exception chained.

Tests run against a real MySQL (TEST_MYSQL_DSN/USER/PASS, default
127.0.0.1:3308) and skip when none is reachable; CI gains a mysql:8.0
service so they execute there.

Ref phpnomad/safemysql-integration#2
@alexstandiford
alexstandiford merged commit d0c8b03 into main Jun 12, 2026
6 of 8 checks passed
@alexstandiford
alexstandiford deleted the feat/pdo-database-strategy branch June 12, 2026 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant