Index

Statement

MMO\pdo\statements · 1 symbol · generated 5 Oct 2026

class

Statement

Statement.php:27

Wrapper on query to pdo.

class MMO\pdo\statements\Statement implements MMO\core\interfaces\iArray, MMO\core\interfaces\iRenderable use MMO\core\classes\tArray, MMO\core\classes\tWithOptions
Namespace
MMO\pdo\statements
Implements
iArray, iRenderable
Uses traits
tArray, tWithOptions

Index

ALL_FLAG
CREATE_IF_NOT_EXISTS_FLAG
CREATE_TEMPORARY_FLAG
DELAYED_FLAG
DISTINCT_FLAG
DISTINCT_ROW_FLAG
HIGH_PRIORITY_FLAG
IF_EXISTS_FLAG
IGNORE_FLAG
LOW_PRIORITY_FLAG
QUICK_FLAG
STRAIGHT_JOIN_FLAG
content
handler
opts
stmt
template
addOptions($opts, $appendList)Merge $opts into the existing options (through merge), rather than replacing them wholesale like setOptions.
bindValue($pdo, $index, $value, $type, $binds)Bind one already-emitted value onto the PDO statement.
clear()Empty the underlying content, keeping the object itself.
clearOptions()Empty the options bag.
count()\Countable::count
execute()Execute the query and set the current statement
fetch($opt)Fetch the first row of the query's result
fetchAll($clear)Fetch all the result of a query
fetchAllObjects($class, $constructFirst, $args, $clear)Fetch all the result of a query as Objects.
fetchObject($class, $constructFirst, $args)Fetch the result of a query as an Object.
fetchValue($key)Fetch the column's value of the first row of the query's result and advance fetch pointer
fetchValues($key)Fetch the column's value of all the row of the query's result
flag($key, $flag, $set)
getIterator()\IteratorAggregate::getIterator
getOption($key, $default)
getOptions()
getPDOStatement()
getPlaceholders()Extract placeholder from template
isEmpty()
jsonSerialize()\JsonSerializable::jsonSerialize -- the raw content is returned as-is (not recursively converted), so json_encode() relies on any nested iArray values being JsonSerializable themselves.
keys()
loadArray($data)Load every entry of a plain array into the content, through offsetSet (so any offsetSet() override defined by the class using this trait, e.g.
offsetExists($key)\ArrayAccess::offsetExists
offsetGet($key)\ArrayAccess::offsetGet
offsetSet($key, $value)\ArrayAccess::offsetSet -- a null $key appends ($bag[] = $value), like a plain PHP array.
offsetUnset($key)\ArrayAccess::offsetUnset -- on a list (sequential integer keys, as produced by $bag[] = ...), the element is spliced out (closing the gap and reindexing), matching \unset() semantics on a plain …
prepare($binds, $sql)Prepare a PDO statement by binding values.
push($key, $fields)
render($opts)
reset()
rowCount()
setOption($key, $value)Set (or, with a null $value, remove) a single option.
setOptions($opts)Replace the whole options bag.
SplitType($key) staticSplit a column:type key used by the INSERT/UPDATE value lists.
toArray()Convert the content to a plain array, recursively converting any nested iArray value (e.g.
__construct($handler, $template, $content, $opts)
__toString()

Constants12

ALL_FLAG

const ALL_FLAG = '#all'

CREATE_IF_NOT_EXISTS_FLAG

const CREATE_IF_NOT_EXISTS_FLAG = '#not-exists'

CREATE_TEMPORARY_FLAG

const CREATE_TEMPORARY_FLAG = '#temporary'

DELAYED_FLAG

const DELAYED_FLAG = '#delayed'

DISTINCT_FLAG

const DISTINCT_FLAG = '#distinct'

DISTINCT_ROW_FLAG

const DISTINCT_ROW_FLAG = '#distinct-row'

HIGH_PRIORITY_FLAG

const HIGH_PRIORITY_FLAG = '#high-priority'

IF_EXISTS_FLAG

const IF_EXISTS_FLAG = '#exists'

IGNORE_FLAG

const IGNORE_FLAG = '#ignore'

LOW_PRIORITY_FLAG

const LOW_PRIORITY_FLAG = '#low-priority'

QUICK_FLAG

const QUICK_FLAG = '#quick'

STRAIGHT_JOIN_FLAG

const STRAIGHT_JOIN_FLAG = '#straight-join'

Properties5

content

protected $content = []

handler

MMO\pdo\interfaces\iHandler $handler
Type
iHandler

opts

protected array $opts = []
Type
array

template

string $template
Type
string

Methods37

addOptions($opts, $appendList)

tWithOptions.php:65

Merge $opts into the existing options (through merge), rather than replacing them wholesale like setOptions.

function addOptions(array $opts, bool $appendList = false): void
$optsarraythe options to merge in
$appendList = falseboolif true, a list-valued option is appended to (rather than replaced by) the corresponding list in $opts -- see \MMO\core\arrays\merge for the exact semantics
returnsvoid
$t->setOptions(['a' => 1, 'tags' => ['x']]); $t->addOptions(['b' => 2, 'tags' => ['y']]); $t->getOptions(); // ['a' => 1, 'tags' => ['y'], 'b' => 2] -- 'tags' is replaced, not appended ($appendList=false)

bindValue($pdo, $index, $value, $type, $binds)

Statement.php:128

Bind one already-emitted value onto the PDO statement.

protected function bindValue( PDOStatement $pdo, int $index, mixed $value, ?string $type, array &$binds ): void
$pdoPDOStatement
$indexintthe 1-based position of the ? this value was emitted for
$valuemixed
$typenull | stringa type hint recorded by the printer ('int', 'bool', 'null', 'lob'/'blob', 'string'), or null to infer it from $value
$bindsarray
returnsvoid
throwsif PDO refuses the value

clear()

tArray.php:25

Empty the underlying content, keeping the object itself.

function clear()
returns
$bag->clear(); // count($bag) === 0 afterwards

clearOptions()

tWithOptions.php:39

Empty the options bag.

function clearOptions(): void
returnsvoid
$t->clearOptions(); // getOptions() === []

fetch($opt)

Statement.php:239

Fetch the first row of the query's result

function fetch(int $opt = PDO::FETCH_ASSOC): mixed
$opt = PDO::FETCH_ASSOCint
returnsmixed

fetchAll($clear)

Statement.php:227

Fetch all the result of a query

function fetchAll(bool $clear = true): array
$clear = trueboolif true clear the pdo statement
returnsarray[colname => value]

fetchAllObjects($class, $constructFirst, $args, $clear)

Statement.php:252

Fetch all the result of a query as Objects.

function fetchAllObjects( string $class, bool $constructFirst = false, array $args = [], bool $clear = true ): array
$classstringthe class name to use
$constructFirst = falseboolif true, the properties will be set after the constructor
$args = []arraythe arguments to pass to the constructor
$clear = trueboolif true clear the pdo statement
returnsarray

fetchObject($class, $constructFirst, $args)

Statement.php:269

Fetch the result of a query as an Object.

function fetchObject(string $class, bool $constructFirst = false, array $args = []): arrayProperties are set before the constructor following this rule : - if the property exists (even private|protected), it is set - else use the magic function __set()
$classstringthe class name to use
$constructFirst = falseboolif true, the properties will be set after the constructor
$args = []arraythe arguments to pass to the constructor
returnsarray

fetchValue($key)

Statement.php:286

Fetch the column's value of the first row of the query's result and advance fetch pointer

function fetchValue(string|int $key = 0): mixed
$key = 0string | intthe column name or index
returnsmixedthe value (null for a SQL NULL), or false if there is no row left or no such column
$stmt = $handler->statement('SELECT email FROM user WHERE id = {id}', ['id' => 1]); $stmt->fetchValue(); // null if user 1 has no email, false if there is no user 1

fetchValues($key)

Statement.php:299

Fetch the column's value of all the row of the query's result

function fetchValues(string|int $key = 0): array
$key = 0string | intthe column name or index
returnsarray

getOption($key, $default)

tWithOptions.php:49
function getOption(string $key, mixed $default = null): mixed
$keystring
$default = nullmixedreturned if $key is not set
returnsmixed
$t->getOption('a', 'fallback'); // the current value of 'a', or 'fallback' if not set

getOptions()

tWithOptions.php:20
function getOptions(): array
returnsarrayevery option currently set
$t->getOptions(); // ['a' => 1, 'tags' => ['x']]

getPlaceholders()

Statement.php:113

Extract placeholder from template

function getPlaceholders(): array
returnsarray<key: {type, required, offset, size}>

isEmpty()

tArray.php:33
function isEmpty()
returnstrue if the underlying content has no elements
$bag->isEmpty(); // true right after clear(), false as soon as an item is set

jsonSerialize()

tArray.php:43

\JsonSerializable::jsonSerialize -- the raw content is returned as-is (not recursively converted), so json_encode() relies on any nested iArray values being JsonSerializable themselves.

function jsonSerialize(): mixed
returnsmixed
json_encode($bag); // e.g. '{"x":1,"0":2}'

keys()

tArray.php:82
function keys(): array
returnsarraythe list of keys currently set
$bag->keys(); // e.g. ['x', 0]

loadArray($data)

tArray.php:71

Load every entry of a plain array into the content, through offsetSet (so any offsetSet() override defined by the class using this trait, e.g. for validation or type coercion, is honored for every entry).

function loadArray(array $data): static
$dataarray
returnsstatic$this, for chaining
$bag->loadArray(['x' => 1, 'y' => 2]); // equivalent to $bag['x'] = 1; $bag['y'] = 2;

offsetExists($key)

tArray.php:130

\ArrayAccess::offsetExists

function offsetExists(mixed $key): bool
$keymixed
returnsbool

offsetSet($key, $value)

tArray.php:122

\ArrayAccess::offsetSet -- a null $key appends ($bag[] = $value), like a plain PHP array.

function offsetSet(mixed $key, mixed $value): void
$keymixed
$valuemixed
returnsvoid

offsetUnset($key)

tArray.php:107

\ArrayAccess::offsetUnset -- on a list (sequential integer keys, as produced by $bag[] = ...), the element is spliced out (closing the gap and reindexing), matching \unset() semantics on a plain PHP list; on an associative array, the key is simply removed.

function offsetUnset(mixed $key): void
$keymixed
returnsvoid
unset($bag[0]); // on a list: every following index shifts down by one, like array_splice()

prepare($binds, $sql)

Statement.php:92

Prepare a PDO statement by binding values.

function prepare(array &$binds = [], ?string &$sql = null): PDOStatementThe bindings are collected BY the render itself ([`Binds`](https://mcp.mmoframework.fr/documentation/mmo.pdo/php/statements/Binds.md#binds)), not derived from the content: only the printer knows which values actually became a `?` -- an identifier renders as `` `name` ``, a raw fragment renders verbatim, and a `$in` array expands to one `?` per item. Deriving them separately drifts from what was rendered and ends in `SQLSTATE[HY000]: column index out of range`.
$binds = []array
$sql = nullnull | string
returnsPDOStatement

setOption($key, $value)

tWithOptions.php:77

Set (or, with a null $value, remove) a single option.

function setOption(string $key, mixed $value): void
$keystring
$valuemixedif null, the option is unset entirely rather than being set to null
returnsvoid
$t->setOption('a', 1);$t->setOption('a', null); // removes 'a' from getOptions()

setOptions($opts)

tWithOptions.php:30

Replace the whole options bag.

function setOptions(array $opts): void
$optsarray
returnsvoid
$t->setOptions(['a' => 1]);

SplitType($key)

staticStatement.php:159

Split a column:type key used by the INSERT/UPDATE value lists.

static function SplitType(string $key): array
$keystringe.g. 'age', 'age:int', 'counter:raw'
returnsarraystring, 1: ?string} the column, and the bind type -- 'raw' meaning "render this value verbatim, do not bind it" (for a SQL expression such as counter+1), null meaning "infer from the value"
Statement::SplitType('age:int'); // ['age', 'int']

toArray()

tArray.php:56

Convert the content to a plain array, recursively converting any nested iArray value (e.g. another object using this same trait) into its own plain-array form as well.

function toArray(): array
returnsarray
$inner = new Bag(); $inner['a'] = 1; $outer = new Bag(); $outer['inner'] = $inner; $outer->toArray(); // ['inner' => ['a' => 1]] -- $inner is recursively expanded, not left as an object

__construct($handler, $template, $content, $opts)

Statement.php:59
function __construct( MMO\pdo\interfaces\iHandler $handler, string $template, array $content = [], array $opts = [] )
$handleriHandler
$templatestringthe query with moustache placeholder
$content = []arraythe content (binds) for the placeholders
$opts = []arrayoptions to pass to renderTpl