Posted on

Moving PHP code from mysql (PHP4) to mysqli (PHP5)

John Coggeshall has written a useful bit of PHP code that will allow an application written for the mysql extension (PHP4) to be used with the new mysqli extension (PHP5).
John writes this:

MySQL2i is a relatively simple compatiability layer between legacy code in PHP 4 which uses the old ext/mysql extension to the new MySQLi extension in PHP 5. Just include this file at the top of your scripts when you only have MySQLi installed and your ext/mysql code should work just fine.

You can grab MySQL2i from here: http://www.coggeshall.org/oss/mysql2i/

And yes, I believe it is possible to link both the mysql and mysqli extensions into PHP5, but it can be tricky in some situations. With the above, it’s no longer necessary. Very nice work, John!

Posted on