Is it possible to use both MySQLi and PDO?

2019-08-12 22:37发布

问题:

Is it possible to use both MySQLi and PDO ? For example, to insert data using MySQLi and then select and work with it using PDO in other part of the project? I have a lot of insert/update code in MySQLi, but decided to switch to PDO?

回答1:

Yes, it's possible. But keep in mind that you'd have two completely separated connections to the MySQL server in any case. The mysqli_* and PDO_MySQL extensions cannot (currently) share a single connection even though they use the same transport driver (MySQLnd)



回答2:

it is, you just need to configure the connection for both.

You're much better off converting it all to PDO though. It will save time in the long run fixing all the security vulnerabilities in Mysqli



标签: php pdo mysqli