Mixing old mysql with PDO

放肆的年华 提交于 2020-01-04 06:02:26

问题


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:


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.



来源:https://stackoverflow.com/questions/1788238/mixing-old-mysql-with-pdo

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!