aalfiann / lazypdo
A PHP class to make lazy load PDO connection to database.
1.0.1
2019-04-30 17:08 UTC
Requires
- php: >=5.4
- ext-pdo: *
This package is auto-updated.
Last update: 2024-10-29 05:59:17 UTC
README
A PHP class to make lazy load PDO connection to database.
You can use LazyPDO to replace the default PDO, when you need to lazy load. No database connection will be made until first call to one of PDO's methods.
Installation
Install this package via Composer.
composer install aalfiann/lazypdo
Usage
require 'vendor/autoload.php'; use aalfiann\LazyPDO; $dsn = 'mysql:hostname=localhost;dbname=test'; $user = 'test'; $password = 'test'; $pdo = new LazyPDO($dns, $user, $password); // doesn't connect yet $pdo->query('SELECT * FROM `table` WHERE 1'); // connection is made before executing query