Methods40
function addTable(MMO\pdo\helpers\Table $table, ?string $name = null): MMO\pdo\helpers\Tablefunction addTableClass(string $class, ?string $name = null): MMO\pdo\helpers\TableAction 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.$this->alert('payment gateway unreachable for 5 minutes.');
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$this->backtraces('unexpected state reached in {method}.', ['method' => __METHOD__]);
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).
| returns | bool | true if the data was actually committed |
function createStatement(
string $table = '',
array|string|null $fields = null,
array|string|null $primary = null,
array|string|null $index = null
): MMO\pdo\statements\CreateStatementCritical 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.$this->critical('unexpected {exception}.', ['exception' => $e]);
Detailed debug information. No-op if DEBUG is currently filtered out by the verbosity mask.
function debug(Stringable|string $message, array $context = []): void$this->debug('set stream [{stream}].', ['stream' => $stream]);
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.function deleteStatement(
?string $table = null,
MMO\core\interfaces\iFilter|array|string|null $filter = null
): MMO\pdo\statements\DeleteStatementfunction disconnect(): voiddo 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.
| $fn | callable | this function is called to do action on the databse |
| returns | bool | true if the handler was actually commited. Inside a transation, do() won't commit directly, until the transaction is commited. |
function dropStatement(?string $table = null, bool $ifExists = false): MMO\pdo\statements\DropStatementSystem is unusable. No-op if EMERGENCY is currently filtered out by the verbosity mask.
function emergency(Stringable|string $message, array $context = []): void$this->emergency('database connection lost.');
Unwind one level of startTransaction, without committing or rolling anything back.
function endTransaction(): bool| returns | bool | true if this was the outermost level (so the caller should now commit for real) |
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.$this->error('failed to write [{file}].', ['file' => $filename]);
function getHandle()| returns | | the connection, null when not connected |
function getTables(): arrayfunction getVerbosity(): int| returns | int | the current verbosity, as a bitmask of iLogLevel::* constants |
$this->getVerbosity() === (iLogLevel::ERROR_PLUS); // true if only errors/critical/alert/emergency are enabled
function hasTable(MMO\pdo\helpers\Table|string $table): boolInteresting 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.$this->info('routing [{request}] ...', ['request' => $request]);
function insertStatement(?string $table = null, array $values = []): MMO\pdo\statements\InsertStatementfunction inTransaction(): boolfunction isConnected(): boolReturn last id in insert.
function lastId(): string|falseLogs 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.$this->log(self::ERROR, 'disk usage at {percent}%.', ['percent' => 92]);
$this->log('error', $caughtException); //string levels are resolved through \MMO\core\debug\flags()
Normal but significant events. No-op if NOTICE is currently filtered out by the verbosity mask.
function notice(Stringable|string $message, array $context = []): void$this->notice('-- START -- ({mode}): {time}', ['mode' => MMO_MODE, 'time' => date('r')]);
Prepare a pdo statement
function prepare(string $query): PDOStatementfunction removeTable(MMO\pdo\helpers\Table|string $table): ?MMO\pdo\helpers\TableAbort 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| returns | bool | true if there was something to roll back |
function selectStatement(
array|string|null $table,
array|string|null $fields = null,
MMO\core\interfaces\iFilter|array|string|null $filter = null
): MMO\pdo\statements\SelectStatementSet the current verbosity mask, replacing whatever it was before.
function setVerbosity(string|int|null $verb = null): void| $verb = null | string | int | null | a bitmask of iLogLevel::* constants, or a level name/expression resolved through \MMO\core\debug\flags() (e.g. 'error+' for iLogLevel::ERROR_PLUS) |
| returns | void | |
$this->setVerbosity(iLogLevel::WARNING_PLUS); // only log warnings and above
$this->setVerbosity('all'); // log everything
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)function statement(?string $template = null, array $content = [], array $opts = []): MMO\pdo\statements\Statementfunction table(string $name): MMO\pdo\helpers\TableTest whether a given level (or set of levels) is currently enabled by this instance's verbosity mask.
function testVerbosity(string|int $level): int| $level | string | int | a iLogLevel::* constant/bitmask, or a level name resolved through \MMO\core\debug\flags() |
| returns | int | the 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
function updateStatement(
?string $table = null,
array $values = [],
MMO\core\interfaces\iFilter|array|string|null $filter = null
): MMO\pdo\statements\UpdateStatementExceptional 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.$this->warning('{count} logs were dropped.', ['count' => 3]);
function __destruct()function __wakeup(): void