Download the PHP package pine3ree/p3-pdo without Composer
On this page you can find all versions of the php package pine3ree/p3-pdo. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package p3-pdo
pine3ree-PDO
A lazy-loading PDO drop-in replacement!
pine3ree-PDO extends PHP ext-PDO in order to provide on demand connection, connection expiration with auto-reconnect and query logging/profiling.
Installation
This version (3.0.x
) of the library requires php ~8.0 || ~8.1.0 || ~8.2.0
.
For php-7.4 support please use version 2.0.x
.
You can install it library using Composer (with "minimum-stability": "dev"):
Documentation
Check the php PDO book for standard ext PDO methods.
Continue reading below for additional methods.
How to use the lazy pdo instance
Just instantiate the provided lazy class as you would with the standard ext-pdo PDO class. A wrapped standard PDO instance will be created on demand when really needed.
By default pine3ree\PDO
and its descendant pine3ree\PDO\Reconnecting\PDO
establish a
database connection on demand.
The methods that trigger the connection are:
pine3ree\PDO::beginTransaction()
;pine3ree\PDO::exec(...)
;pine3ree\PDO::prepare(...)
;pine3ree\PDO::query(...)
;pine3ree\PDO::quote(...)
;pine3ree\PDO::execute(...)
;
How to enable query-profiling
Query logging/profiling can be achieved via the provided profiling class and passing another pdo instance (either a standard ext-pdo instance or an instance of a class extending it (such as the lazy-pdo in this package) in the constructor:
You can retrieve the recorded information by calling the pine3ree\PDO\Profiling\PDO::getLog()
method.
How to use the auto-reconnecting/connection-expiration instance
Use the provided reconnecting-pdo class with an extra $ttl
constructor argument:
Additional methods
pine3ree\PDO::execute(): \PDOStatement|false
combines \PDO::prepare()
and \PDOStatement::execute()
into one method call,
returning false
if either the statement preparation or execution fails.
This method is inherited by pine3ree\PDO\Reconnecting\PDO
.
pine3ree\PDO::isConnected(): bool
checks if we have an established database connection.
This method is inherited by pine3ree\PDO\Reconnecting\PDO
and also implemented in pine3ree\PDO\Profiling\PDO
.
pine3ree\PDO\Profiling\PDO::getLog(): array
returns recorded profiling information about all the executed statements in the following format:
pine3ree\PDO\Reconnecting\PDO::getConnectionCount(): int
returns the number of database connections performed so far
All versions of p3-pdo with dependencies
ext-pdo Version *