Alpha ZealPHP is early-stage and under active development. APIs may change between minor versions until v1.0. Feedback and bug reports welcome on GitHub.
API Index — Namespaces, Packages, Reports, Indices

PdoDriver
in package
implements PoolDriver

FinalYes

{@see PoolDriver} for \PDO connections — works with any PDO driver (MySQL, PostgreSQL, SQLite, SQL Server, Oracle, …).

NOTE: the pool bounding benefit applies to every PDO driver, but the coroutine non-blocking benefit does not: under HOOK_ALL only mysqlnd-based PDO_MYSQL rides php_stream and yields. libpq-based PDO_PGSQL, Oracle/ODBC, etc. do their own C-side socket I/O and block the worker per query — the pool still caps their connection count, but you don't get coroutine concurrency during the query.

Tags
implements

Table of Contents

Interfaces

PoolDriver
Connection-library adapter for {@see DbConnectionPool}.

Properties

$factory  : callable(): PDO

Methods

__construct()  : mixed
begin()  : void
commit()  : void
connect()  : TConn
Open a fresh connection. Throwing here propagates out of the pool's fill/refill path (the caller sees the underlying connect error).
disconnect()  : void
Tear down a connection. PDO closes on reference release so this can be a no-op there; mysqli needs an explicit close().
dsn()  : self
Build a driver from a DSN. ERRMODE_EXCEPTION + FETCH_ASSOC are applied unless overridden in $options.
isAlive()  : bool
Liveness probe — run $query and return false if the connection is dead (server closed it while idle). Only called when the pool was configured with a validation query.
rollback()  : void
rollbackIfNeeded()  : void
Make a borrowed connection transaction-clean before it returns to the pool: roll back any transaction the borrower left open. Drivers that cannot introspect transaction state (mysqli has no inTransaction()) may no-op — see {@see MysqliDriver} for the documented limitation.

Properties

Methods

__construct()

public __construct(callable(): PDO $factory) : mixed
Parameters
$factory : callable(): PDO

Builds a fresh PDO connection.

begin()

public begin(object $conn) : void
Parameters
$conn : object

commit()

public commit(object $conn) : void
Parameters
$conn : object

connect()

Open a fresh connection. Throwing here propagates out of the pool's fill/refill path (the caller sees the underlying connect error).

public connect() : TConn
Return values
TConn

disconnect()

Tear down a connection. PDO closes on reference release so this can be a no-op there; mysqli needs an explicit close().

public disconnect(object $conn) : void
Parameters
$conn : object

dsn()

Build a driver from a DSN. ERRMODE_EXCEPTION + FETCH_ASSOC are applied unless overridden in $options.

public static dsn(string $dsn[, string|null $username = null ][, string|null $password = null ][, array<int, mixed> $options = [] ]) : self
Parameters
$dsn : string
$username : string|null = null
$password : string|null = null
$options : array<int, mixed> = []
Return values
self

isAlive()

Liveness probe — run $query and return false if the connection is dead (server closed it while idle). Only called when the pool was configured with a validation query.

public isAlive(object $conn, string $query) : bool
Parameters
$conn : object
$query : string
Return values
bool

rollback()

public rollback(object $conn) : void
Parameters
$conn : object

rollbackIfNeeded()

Make a borrowed connection transaction-clean before it returns to the pool: roll back any transaction the borrower left open. Drivers that cannot introspect transaction state (mysqli has no inTransaction()) may no-op — see {@see MysqliDriver} for the documented limitation.

public rollbackIfNeeded(object $conn) : void
Parameters
$conn : object
On this page