Gonzalo Ayuso's Blog: Database connection pooling with PHP and gearman
Handling Database connections with PHP is pretty straightforward. Just open database connection, perform the actions we need, and close it. There's a little problem. We cannot create a pool of database connections. We need to create the connection in every request. Create and destroy, again and again. [...] In this post I'm going to try to explain a personal experiment to create a connection pooling using gearman.
He includes a basic database connection example with PDO, logging into a single database and fetching all of the results. To integrate this into the gearman functionality, he creates a configuration class to hold connection details and the worker code (along with some libraries to help manage the connections) that gets the results, serializes them and returns them back to the calling script.