PHPackages                             gonzie/pdoload - 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. gonzie/pdoload

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

gonzie/pdoload
==============

Small PDO wrapper to provide read/write split and load balancing in one line of code.

v0.3.2(8y ago)131964[1 issues](https://github.com/gonzie/pdoload/issues)MITPHPPHP &gt;=7.0

Since Feb 4Pushed 6y ago1 watchersCompare

[ Source](https://github.com/gonzie/pdoload)[ Packagist](https://packagist.org/packages/gonzie/pdoload)[ RSS](/packages/gonzie-pdoload/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (2)Versions (6)Used By (0)

![Travis CI build](https://camo.githubusercontent.com/ed7274694b01020b8c98c48db8383d27dd18b81d025d11314384c5326248029c/68747470733a2f2f7472617669732d63692e6f72672f676f6e7a69652f70646f6c6f61642e7376673f6272616e63683d6d6173746572)![PHP from Packagist](https://camo.githubusercontent.com/20448b5b8fdf5d780995746f3a19ac0dc695deaa286ba3f2f814caa3c6408426/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f676f6e7a69652f70646f6c6f61642e737667)![License from pugx](https://camo.githubusercontent.com/24d5fde7d355bf11831b24eb602aaf62ff307d5b73f4dd374f43c26622793121/68747470733a2f2f706f7365722e707567782e6f72672f676f6e7a69652f70646f6c6f61642f6c6963656e73652e737667)

PDOLoad
=======

[](#pdoload)

***PDOLoad*** is a small PDO wrapper/abstraction layer to provide read/write endpoints and load balancing capabilities in one line of code. Load balancing is usually include within most major PHP Frameworks however when working with large legacy projects it's hard to come by.

**Main Features**

- Add multiple read and write endpoints.
- ***One line implementation***. No need to rewrite your PDO queries.
- Transaction aware. Any reads while a transaction is active will be performed on the write connection.

Getting started
---------------

[](#getting-started)

- PHP &gt;= 7.0 is required
- Install PDOLoad using composer (recommmended) or manually
- Configure your connections and you're ready to go!

Installing with Composer
------------------------

[](#installing-with-composer)

```
composer require gonzie/pdoload

```

How to use
----------

[](#how-to-use)

PDOLoad gives you as much choice as possible with little to no modification required. A normal PDO connection would be set like:

```
$dbh = new PDO('mysql:host=localhost;dbname=testdb;charset=utf8mb4', 'username', 'password');
```

(most basic set up)

To use a minimalistic version of PDOLoad you would amend the code as follows:

```
$dbh = new Gonzie\PDOLoad\PDOLoad('mysql:host=localhost;dbname=testdb;charset=utf8mb4', 'username', 'password');
```

Alternatively, to use PDOLoad to it's full abilities, and for what it was actually made for, you can set up by passing an `array` with settings.

```
