Index

aHandler

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

class

aHandler

aHandler.php:29

Abstract class that builds query

abstract class MMO\pdo\classes\aHandler implements MMO\core\interfaces\iLogEmitter, MMO\pdo\interfaces\iHandler use MMO\core\classes\tLogEmitter
Namespace
MMO\pdo\classes
Implements
iLogEmitter, iHandler
Uses traits
tLogEmitter
Any export can return a string (a part of a query or a complete query) or an array where the first item is a query with placeholders and the rest are the bound values to the given placeholders

Index

handleHandle to sql object
tablePrefix
tables
transCount
verbosity
addTable($table, $name)
addTableClass($class, $name)
alert($message, $context)Action must be taken immediately.
backtraces($message, $context)Force-log a message at INFO level together with a full stack trace/memory snapshot (iLogLevel::BACKTRACE), bypassing the verbosity mask entirely (any non-zero verbosity is enough to trigger it).
commit()Alias to \PDO::commit().
createStatement($table, $fields, $primary, $index)
critical($message, $context)Critical conditions. No-op if CRITICAL is currently filtered out by the verbosity mask.
debug($message, $context)Detailed debug information.
debugName()Human-readable identifier used as the default {origin} in this instance's log messages.
deleteStatement($table, $filter)
disconnect()
do($fn)do a safe transaction on the database if an exception is thrown, it rollbacks the database
dropStatement($table, $ifExists)
emergency($message, $context)System is unusable. No-op if EMERGENCY is currently filtered out by the verbosity mask.
endTransaction()Unwind one level of startTransaction, without committing or rolling anything back.
error($message, $context)Runtime errors that do not require immediate action but should typically be logged and monitored.
getHandle()
getTables()
getVerbosity()
hasTable($table)
info($message, $context)Interesting events. No-op if INFO is currently filtered out by the verbosity mask.
insertStatement($table, $values)
inTransaction()
isConnected()
lastId()Return last id in insert.
log($level, $message, $context)Logs with an arbitrary level.
notice($message, $context)Normal but significant events.
prepare($query)Prepare a pdo statement
removeTable($table)
rollBack()Abort the whole transaction, whatever the nesting depth: SQL has no partial rollback without savepoints, so one rollback discards every level at once and resets $transCount to zero.
selectStatement($table, $fields, $filter)
setVerbosity($verb)Set the current verbosity mask, replacing whatever it was before.
startTransaction()Safe Alias to \PDO::beginTranscation() if inside another transaction, doesn't throw an exception and ignore call.
statement($template, $content, $opts)
table($name)
testVerbosity($level)Test whether a given level (or set of levels) is currently enabled by this instance's verbosity mask.
updateStatement($table, $values, $filter)
warning($message, $context)Exceptional occurrences that are not errors.
__destruct()
__wakeup()

Properties5

handle

Handle to sql object

#[MMO\core\attributes\Serialize(false)] protected $handle = null

tablePrefix

string $tablePrefix = ''
Type
string

tables

#[MMO\core\attributes\Serialize(false)] protected array $tables = []
Type
array

transCount

#[MMO\core\attributes\Serialize(false)] protected int $transCount = 0
Type
int

verbosity

#[MMO\core\attributes\Serialize(order: -1000)] protected int $verbosity = 31
Type
int

Methods40

alert($message, $context)

tLogEmitter.php:121

Action must be taken immediately.

function alert(Stringable|string $message, array $context = []): voidExample: Entire website down, database unavailable, etc. This should trigger the SMS alerts and wake you up.
$messageStringable | string
$context = []array
returnsvoid
$this->alert('payment gateway unreachable for 5 minutes.');

backtraces($message, $context)

tLogEmitter.php:234

Force-log a message at INFO level together with a full stack trace/memory snapshot (iLogLevel::BACKTRACE), bypassing the verbosity mask entirely (any non-zero verbosity is enough to trigger it).

function backtraces(string $message = ' -- TRACES -- ', array $context = []): void
$message = ' -- TRACES -- 'string
$context = []array
returnsvoid
$this->backtraces('unexpected state reached in {method}.', ['method' => __METHOD__]);

commit()

aHandler.php:167

Alias to \PDO::commit(). Only the outermost call actually commits: a nested one just unwinds one level of

function commit(): boolNOTE: this used to gate the real commit on `endTransaction()`, which returned `!$this->inTransaction()` -- and inTransaction() consults \PDO::inTransaction(), which is still true at that point precisely BECAUSE nothing has been committed yet. The condition could therefore never be satisfied and \PDO::commit() was never reached: `do()` left its transaction open, the data stayed invisible to every other connection, and
See
startTransaction., disconnect then rolled the whole thing back. Verified directly (a second connection saw 0 rows).
returnsbooltrue if the data was actually committed

critical($message, $context)

tLogEmitter.php:138

Critical conditions. No-op if CRITICAL is currently filtered out by the verbosity mask.

function critical(Stringable|string $message, array $context = []): voidExample : Application component unavailable, unexpected exception.
$messageStringable | string
$context = []array
returnsvoid
$this->critical('unexpected {exception}.', ['exception' => $e]);

debug($message, $context)

tLogEmitter.php:219

Detailed debug information. No-op if DEBUG is currently filtered out by the verbosity mask.

function debug(Stringable|string $message, array $context = []): void
$messageStringable | string
$context = []array
returnsvoid
$this->debug('set stream [{stream}].', ['stream' => $stream]);

debugName()

tLogEmitter.php:30

Human-readable identifier used as the default {origin} in this instance's log messages.

function debugName(): stringOverride this in a class using the trait to show something more specific than the bare classname.
returnsstring

do($fn)

aHandler.php:127

do a safe transaction on the database if an exception is thrown, it rollbacks the database

function do(callable $fn): boolNOTE: this used to catch only \PDOException -- but [`Statement::execute`](https://mcp.mmoframework.fr/documentation/mmo.pdo/php/statements/Statement.md#statement-execute) wraps every driver error into an [`ePDO`](https://mcp.mmoframework.fr/documentation/mmo.pdo/php/exceptions/ePDO.md#epdo) (an eRuntime, NOT a PDOException), so the single most likely failure inside $fn escaped without rolling anything back, leaving the transaction open and
See
$transCount stuck above zero for the rest of the connection's life. Verified directly.
$fncallablethis function is called to do action on the databse
returnsbooltrue if the handler was actually commited. Inside a transation, do() won't commit directly, until the transaction is commited.

dropStatement($table, $ifExists)

aHandler.php:249
function dropStatement(?string $table = null, bool $ifExists = false): MMO\pdo\statements\DropStatement
$table = nullnull | string
$ifExists = falsebool
returnsDropStatement

emergency($message, $context)

tLogEmitter.php:103

System is unusable. No-op if EMERGENCY is currently filtered out by the verbosity mask.

function emergency(Stringable|string $message, array $context = []): void
$messageStringable | string
$context = []array
returnsvoid
$this->emergency('database connection lost.');

endTransaction()

aHandler.php:199

Unwind one level of startTransaction, without committing or rolling anything back.

function endTransaction(): bool
returnsbooltrue if this was the outermost level (so the caller should now commit for real)

error($message, $context)

tLogEmitter.php:154

Runtime errors that do not require immediate action but should typically be logged and monitored.

function error(Stringable|string $message, array $context = []): voidNo-op if ERROR is currently filtered out by the verbosity mask.
$messageStringable | string
$context = []array
returnsvoid
$this->error('failed to write [{file}].', ['file' => $filename]);

getHandle()

aHandler.php:75
function getHandle()
returnsthe connection, null when not connected

getVerbosity()

tLogEmitter.php:38
function getVerbosity(): int
returnsintthe current verbosity, as a bitmask of iLogLevel::* constants
$this->getVerbosity() === (iLogLevel::ERROR_PLUS); // true if only errors/critical/alert/emergency are enabled

info($message, $context)

tLogEmitter.php:204

Interesting events. No-op if INFO is currently filtered out by the verbosity mask.

function info(Stringable|string $message, array $context = []): voidExample: User logs in, SQL logs.
$messageStringable | string
$context = []array
returnsvoid
$this->info('routing [{request}] ...', ['request' => $request]);

log($level, $message, $context)

tLogEmitter.php:81

Logs with an arbitrary level.

function log($level, Stringable|string $message, array $context = []): voidNOTE: $level is filtered against the current [`setVerbosity()`](https://mcp.mmoframework.fr/documentation/mmo.pdo/php/classes/aHandler.md#ahandler-setverbosity): if the level is masked out, nothing is logged/dispatched at all. Return type is `void` (not the dispatched Log) to satisfy \Psr\Log\LoggerInterface.
$level
$messageStringable | string
$context = []arrayignored if $message is a Log
returnsvoid
$this->log(self::ERROR, 'disk usage at {percent}%.', ['percent' => 92]); $this->log('error', $caughtException); //string levels are resolved through \MMO\core\debug\flags()

notice($message, $context)

tLogEmitter.php:187

Normal but significant events. No-op if NOTICE is currently filtered out by the verbosity mask.

function notice(Stringable|string $message, array $context = []): void
$messageStringable | string
$context = []array
returnsvoid
$this->notice('-- START -- ({mode}): {time}', ['mode' => MMO_MODE, 'time' => date('r')]);

rollBack()

aHandler.php:184

Abort the whole transaction, whatever the nesting depth: SQL has no partial rollback without savepoints, so one rollback discards every level at once and resets $transCount to zero.

function rollBack(): bool
returnsbooltrue if there was something to roll back

setVerbosity($verb)

tLogEmitter.php:64

Set the current verbosity mask, replacing whatever it was before.

function setVerbosity(string|int|null $verb = null): void
$verb = nullstring | int | nulla bitmask of iLogLevel::* constants, or a level name/expression resolved through \MMO\core\debug\flags() (e.g. 'error+' for iLogLevel::ERROR_PLUS)
returnsvoid
$this->setVerbosity(iLogLevel::WARNING_PLUS); // only log warnings and above $this->setVerbosity('all'); // log everything

startTransaction()

aHandler.php:145

Safe Alias to \PDO::beginTranscation() if inside another transaction, doesn't throw an exception and ignore call.

function startTransaction(): boolYou MUST call commit() as many times you called startTransaction() (even if it had no effect)
returnsbool

statement($template, $content, $opts)

aHandler.php:213
function statement(?string $template = null, array $content = [], array $opts = []): MMO\pdo\statements\Statement
$template = nullnull | string
$content = []array
$opts = []array
returnsStatement

testVerbosity($level)

tLogEmitter.php:50

Test whether a given level (or set of levels) is currently enabled by this instance's verbosity mask.

function testVerbosity(string|int $level): int
$levelstring | inta iLogLevel::* constant/bitmask, or a level name resolved through \MMO\core\debug\flags()
returnsintthe bits of $level that are currently enabled (0 if none of them are)
$this->testVerbosity(self::DEBUG); // non-zero if debug-level logging is currently enabled $this->testVerbosity('error'); // same, using the string form

warning($message, $context)

tLogEmitter.php:172

Exceptional occurrences that are not errors. No-op if WARNING is currently filtered out by the verbosity mask.

function warning(Stringable|string $message, array $context = []): voidExample: Use of deprecated APIs, poor use of an API, undesirable things that are not necessarily wrong.
$messageStringable | string
$context = []array
returnsvoid
$this->warning('{count} logs were dropped.', ['count' => 3]);
Inherited members (24)
ConstantsDeclared byDescription
ALERTiLogLevelAlert: Action must be taken immediately.
ALLiLogLevelMask for all
ALL_PLUSiLogLeveldebug everything
BACKTRACEiLogLevel
CRITICALiLogLevelCritical: Critical conditions.
DEBUGiLogLevelDebug: Detailed debug information.
DEEPiLogLeveldebug everything with arguments
EMERGENCYiLogLevelEmergency: System is unusable.
ERRORiLogLevelError: Runtime errors that do not require immediate action but should typically be logged and monitored.
ERROR_PLUSiLogLevelMask for all error
FATALiLogLevelMask for all fatal error
INFOiLogLevelInfo: Interesting events.
INFO_PLUSiLogLevelMask for all errors/warning/notices/info
MEMORYiLogLevelinclude backtrace object
NOTICEiLogLevelNotice: Normal but significant events.
NOTICE_PLUSiLogLevelMask for all errors/warning/notices/info
TRACEiLogLevelinclude backtrace as origins
WARNINGiLogLevelWarning: Exceptional occurrences that are not errors.
WARNING_PLUSiLogLevelMask for all errors and warnings
MethodsDeclared byDescription
configureStatement($statement)iHandler
connect()iHandler
getHref()iHandler
tableExists($name)iHandler
tables()iHandler