tags:

views:

46

answers:

1

I'm writing an application which makes use of some legacy code. The newer code uses PDO, while the older uses the original mysql library.

A large amount of data is input in a transaction in the first code, so that I can roll back on error, but the legacy code is called at some points and needs to see the same data; unless the connection is shared, the legacy code can't see the changes made by the newer code.

Somewhere down there PDO must have a connection handle for the database; is there any way to get at it? Is there another way to coerce the old mysql library calls to use the PDO connection? Is there anyway to open the old style connection, then tell PDO to use that connection? Any other ideas?

+1  A: 

I don't think what you want is possible : I've never seen that done, as each library (PDO, mysql, and mysqli) uses its own connection to the Dabatase -- which means, as you notices, that connections established using one of those are not shared with the others.

I suppose you'll have to find a way to migrate all of your code in one shot -- at least, for portions that need to work on the same transactions.

Pascal MARTIN
Sad, but true. Next step - bringing all that crap old code up to date. *sigh*
El Yobo
As an addendum to this, I ended up writing a wrapper around the required MySQL functions so that they actually used the PDO functions underneath; we're still migrating all the old MySQL code, but this allows us to roll ahead in the mean time anyway.
El Yobo