WpdbConnectionAdapter
in package
implements
ConnectionAdapterInterface
WordPress database adapter — wraps the global `$wpdb` behind the framework {@see ConnectionAdapterInterface} seam.
This is the only object in the WordPress adapter that knows about $wpdb.
Everything above it (query builders, repositories, domain) depends on the
framework contract, never on $wpdb directly, so the same code runs unchanged
on every host.
Records and conditions are plain assoc arrays at this boundary; rows come back
as assoc arrays (ARRAY_A). Mapping rows to domain entities happens above, in
repositories.
The record helpers (insert(), update(), delete(), find(), findAll())
accept a logical or an already-prefixed table name: the dialect prepends the
$wpdb prefix when it is missing (see WpdbSqlDialect). Raw SQL passed
to execute(), fetch() and fetchAll() is sent as written.
Public surface: the consumer's composition root registers it for the framework
ConnectionAdapterInterface and references it when wiring the
$wpdb-backed services above it.
Table of Contents
Interfaces
- ConnectionAdapterInterface
Properties
Methods
- __construct() : mixed
- cursor() : iterable<string|int, mixed>
- delete() : void
- dialect() : SqlDialectInterface
- execute() : int
- fetch() : array<string|int, mixed>|null
- fetchAll() : array<string|int, mixed>
- find() : array<string|int, mixed>|null
- findAll() : array<string|int, mixed>
- insert() : int
- supports() : bool
- transaction() : mixed
- update() : void
-
compileConditions()
: array{0: string, 1: array
} - Compile an equality WHERE clause from a column => value map.
- isAssoc() : bool
- placeholderFor() : string
- prepare() : string
- Render a $wpdb->prepare()-safe SQL string from positional or named params.
- replaceFirst() : string
Properties
$dialect
private
SqlDialectInterface
$dialect
$wpdb
private
wpdb
$wpdb
Methods
__construct()
public
__construct(wpdb $wpdb[, SqlDialectInterface|null $dialect = null ]) : mixed
Parameters
- $wpdb : wpdb
- $dialect : SqlDialectInterface|null = null
cursor()
public
cursor(string $sql[, array<string|int, mixed> $params = [] ]) : iterable<string|int, mixed>
Parameters
- $sql : string
- $params : array<string|int, mixed> = []
Return values
iterable<string|int, mixed>delete()
public
delete(string $table, array<string|int, mixed> $conditions) : void
Parameters
- $table : string
- $conditions : array<string|int, mixed>
dialect()
public
dialect() : SqlDialectInterface
Return values
SqlDialectInterfaceexecute()
public
execute(string $sql[, array<string|int, mixed> $params = [] ]) : int
Parameters
- $sql : string
- $params : array<string|int, mixed> = []
Return values
intfetch()
public
fetch(string $sql[, array<string|int, mixed> $params = [] ]) : array<string|int, mixed>|null
Parameters
- $sql : string
- $params : array<string|int, mixed> = []
Return values
array<string|int, mixed>|nullfetchAll()
public
fetchAll(string $sql[, array<string|int, mixed> $params = [] ]) : array<string|int, mixed>
Parameters
- $sql : string
- $params : array<string|int, mixed> = []
Return values
array<string|int, mixed>find()
public
find(string $table, array<string|int, mixed> $conditions) : array<string|int, mixed>|null
Parameters
- $table : string
- $conditions : array<string|int, mixed>
Return values
array<string|int, mixed>|nullfindAll()
public
findAll(string $table[, array<string|int, mixed> $conditions = [] ]) : array<string|int, mixed>
Parameters
- $table : string
- $conditions : array<string|int, mixed> = []
Return values
array<string|int, mixed>insert()
public
insert(string $table, array<string|int, mixed> $record) : int
Parameters
- $table : string
- $record : array<string|int, mixed>
Return values
intsupports()
public
supports(Capability $feature) : bool
Parameters
- $feature : Capability
Return values
booltransaction()
public
transaction(callable $work) : mixed
Parameters
- $work : callable
update()
public
update(string $table, array<string|int, mixed> $record) : void
Parameters
- $table : string
- $record : array<string|int, mixed>
compileConditions()
Compile an equality WHERE clause from a column => value map.
private
compileConditions(array<string, mixed> $conditions) : array{0: string, 1: array}
Parameters
- $conditions : array<string, mixed>
Return values
array{0: string, 1: arrayisAssoc()
private
isAssoc(array<int|string, mixed> $array) : bool
Parameters
- $array : array<int|string, mixed>
Return values
boolplaceholderFor()
private
placeholderFor(mixed $value) : string
Parameters
- $value : mixed
Return values
stringprepare()
Render a $wpdb->prepare()-safe SQL string from positional or named params.
private
prepare(string $sql, array<int|string, mixed> $params) : string
Named params (:name) are rewritten to %s/%d/%f placeholders in
declaration order; positional ? placeholders are mapped from the list.
Parameters
- $sql : string
- $params : array<int|string, mixed>
Return values
stringreplaceFirst()
private
replaceFirst(string $haystack, string $needle, string $replace) : string
Parameters
- $haystack : string
- $needle : string
- $replace : string