PDO database strategy — maintained replacement for SafeMySQL - #16
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements the replacement path from phpnomad/safemysql-integration#2:
PdoConnection+PdoDatabaseStrategy+PdoAtomicOperationStrategywith 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.