I'm having an issue with the reusability of the ezcDbHandler within my project. 

ezcDbHandler directly extends the internal PDO class; which when instantiated, 
the actual DB connection. This causes problems when I already have a connection.

Specifically, the issue is that I wish to use ezcWorkflowDatabaseTiein, which 
an ezcDbHandler object in it's constructor. This is fine, except that in order 
to fulfill this requirement,
I need to instantiate a /second/ connection to the DB with ezcDbHandler instead 
of re-using the PDO
instance I already have elsewhere in my code.

A solution to this is to make ezcDbHandler a facade for the PDO instance, and 
allow passing
in an existing PDO instance instead of a DSN.

The only backwards compatibility issue is that any code that currently does:

$db = new ezcDbHandler(...);
// other stuff…

if ($db instanceof PDO) {
        // will now be false

But it allows:

$pdoInstance = new PDO(…);
// other stuff

$dbHandler = new ezcDbHandler(null, $pdoInstance);

You can find a readable patch for this relatively simple change here: 
And this is the actual patch, with the whitespace changes (I put an is_array() 
around the dbParams too, bumping the indent):

What are the chances of this being integrated into Zeta?

- Davey

Reply via email to