I have created a SQL Database connection manager that can handle a list of read, write, or named connections and initiate a PDO instance of any one. This is designed to help with load balancing SQL servers to distribute the load.
The idea for this came from the Aura SQL library, which I was really hoping to use, but unfortunately their documentation was quite incorrect… So this just takes one component of their library, the connection manager.
You can get my Connection Manager from This Gist. I’m sorry its not a Composer package, but I likely will do that if some time soon.
And here is a usage example:
You can also change the default options that will get passed to the PDO instance:
You can find documentation on the different options Here
Additionally, if you have made your own class that extends PDO, you can use them with this connection manager like so:
It must be compatible with the same style of initiation as PDO.
I hope this helps some people out, as its something that I couldn’t find a nice stand-alone package for. I will move it to Composer soon hopefully, and here is the link to it one more time, Enjoy - and attribute it to me if you want, its Beerware at this stage.