PHPackages                             alejoluc/lazypdo - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. alejoluc/lazypdo

ActiveLibrary[Database &amp; ORM](/categories/database)

alejoluc/lazypdo
================

PDO Drop-in replacement that only makes a connection when needed

0.2.6(8y ago)0276MITPHPPHP &gt;=5.6.0

Since Jan 19Pushed 8y ago1 watchersCompare

[ Source](https://github.com/alejoluc/LazyPDO)[ Packagist](https://packagist.org/packages/alejoluc/lazypdo)[ Docs](https://github.com/alejoluc/LazyPDO)[ RSS](/packages/alejoluc-lazypdo/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependenciesVersions (3)Used By (0)

alejoluc\\LazyPDO
=================

[](#alejoluclazypdo)

Contents
--------

[](#contents)

1. [Installation](#installation)
2. [On Connection Errors](#on-connection-errors)
3. [Usage](#usage)
4. [On Dependency Injection Containers](#why-not-use-a-dependency-injection-container-instead)

This package provides a drop-in replacement for PHP's native PDO class.

The LazyPDO class is *lazy* in the sense that, unlike native PDO, it will not attempt to connect to the database server upon instantiation. Instead, it will store all the connection details and wait until it actually needs a connection, for example, to execute a query.

This is useful if you have an effective caching mechanism in place, and the database may not need to respond to all requests.

LazyPDO *extends* PDO, so any instance of LazyPDO [*is an*](https://en.wikipedia.org/wiki/Liskov_substitution_principle) instance of PDO. That means you can pass along an instance of LazyPDO anywhere a PDO instance is expected.

```
