WpdbConditionCompiler
in package
implements
ConditionCompilerInterface
Condition compiler for WordPress' `$wpdb` (MySQL / MariaDB).
Translates abstract query conditions (column + operator + value) into
$wpdb-flavored SQL fragments with named placeholders. Table-agnostic and
reusable across repositories; it is the WordPress counterpart of the Moodle
adapter's SqlGenerator and implements the framework
ConditionCompilerInterface port directly (the port is OSS, so no
core-side binding subclass is needed).
The few platform idioms it needs — TEXT/CLOB comparison and IN-list assembly —
are delegated to the injected WpdbSqlDialect so the SQL stays MySQL-
correct; everything else follows MySQL syntax (LIKE, BETWEEN, IS TRUE).
Public surface: the consumer's composition root registers it and aliases the framework ConditionCompilerInterface onto it.
Table of Contents
Interfaces
- ConditionCompilerInterface
Properties
Methods
- __construct() : mixed
-
compileCondition()
: array{0: string, 1: array
} - Compile a single SQL condition based on the {@see Operator} enum.
-
compileBetween()
: array{0: string, 1: array
} - Range comparison (BETWEEN min AND max).
-
compileBinary()
: array{0: string, 1: array
} - Equality / relational comparison (EQ, NEQ, GT, GTE, LT, LTE).
-
compileInList()
: array{0: string, 1: array
} - Set membership (IN / NOT IN).
-
compileLike()
: array{0: string, 1: array
} - Pattern matching (LIKE). Wildcards must already live in the value.
-
compileNullOrBool()
: array{0: string, 1: array
} - NULL / boolean comparison (IS / IS NOT).
Properties
$dialect
private
WpdbSqlDialect
$dialect
Methods
__construct()
public
__construct(WpdbSqlDialect $dialect) : mixed
Parameters
- $dialect : WpdbSqlDialect
compileCondition()
Compile a single SQL condition based on the {@see Operator} enum.
public
compileCondition(string $column, Operator $op, mixed $value, mixed $value2, string $paramPrefix) : array{0: string, 1: array}
Parameters
- $column : string
-
SQL column reference (e.g.
item.status) - $op : Operator
-
Comparison operator
- $value : mixed
-
Primary value (may be null for IS / IS NOT NULL)
- $value2 : mixed
-
Secondary value (e.g. BETWEEN upper bound)
- $paramPrefix : string
-
Unique prefix used to name the emitted placeholders
Tags
Return values
array{0: string, 1: array[SQL fragment, named parameters]
compileBetween()
Range comparison (BETWEEN min AND max).
private
compileBetween(string $column, mixed $value, mixed $value2, string $paramPrefix) : array{0: string, 1: array}
Parameters
- $column : string
- $value : mixed
- $value2 : mixed
- $paramPrefix : string
Return values
array{0: string, 1: arraycompileBinary()
Equality / relational comparison (EQ, NEQ, GT, GTE, LT, LTE).
private
compileBinary(string $column, Operator $op, mixed $value, string $paramPrefix, bool $isTextColumn) : array{0: string, 1: array}
Parameters
- $column : string
- $op : Operator
- $value : mixed
- $paramPrefix : string
- $isTextColumn : bool
Return values
array{0: string, 1: arraycompileInList()
Set membership (IN / NOT IN).
private
compileInList(string $column, Operator $op, mixed $value, string $paramPrefix) : array{0: string, 1: array}
Parameters
- $column : string
- $op : Operator
- $value : mixed
- $paramPrefix : string
Return values
array{0: string, 1: arraycompileLike()
Pattern matching (LIKE). Wildcards must already live in the value.
private
compileLike(string $column, mixed $value, string $paramPrefix) : array{0: string, 1: array}
Parameters
- $column : string
- $value : mixed
- $paramPrefix : string
Return values
array{0: string, 1: arraycompileNullOrBool()
NULL / boolean comparison (IS / IS NOT).
private
compileNullOrBool(string $column, Operator $op, mixed $value) : array{0: string, 1: array}
Parameters
- $column : string
- $op : Operator
- $value : mixed