Page MenuHomeDevCentral

Improve PDO support with prepare and bind
DraftPublic

Authored by dereckson on Fri, Oct 31, 22:49.
This is a draft revision that has not yet been submitted for review.

Details

Summary

Enhances support for the prepare/bind/execute query workflow,
making it easier to write Dependency Injection (DI) resistant code.

This change introduces a Query abstract class, implemented by PDOQuery,
with the following methods:

  • query: executes the query and returns a PDODatabaseResult
  • withValue and bind: sets a parameter value or bind it to a variable
  • bindInOutParameter: sets a parameter for stored procedure calls

The PDOQuery instance is created by the PDOEngine class,
which calls the prepare() method with an SQL query as its argument.

While PDO directly calls all methods on the statement class, this
engine/query/result separation improves the overall separation of concerns.

Ref T2169

Test Plan

Orbeon Forms Reader for Obsidian Workspaces has plan for PDO support in D3835.

Diff Detail

Repository
rKERUALD Keruald libraries development repository
Lint
Lint Errors
SeverityLocationCodeMessage
Errordatabase/src/Query/Query.php:9PHPCS.E.Generic.NamingConventions.ConstructorName.OldStyleGeneric.NamingConventions.ConstructorName.OldStyle
Unit
No Test Coverage
Branch
pdo
Build Status
Buildable 6125
Build 6409: arc lint + arc unit

Event Timeline

dereckson held this revision as a draft.
database/src/Query/Query.php
7

Guess we can use DatabaseQuery to avoid this confusion, like for DatabaseResult / DatabaseEngine.

dereckson edited the summary of this revision. (Show Details)

Pass by reference when we call afterwards bindParam