If you have a site that is using mysql_* functions, upgrading your PHP will soon be hassle since Zend is planning on removing those functions. If you are in that group, I have written an object which will mimic the exact functionality of mysql_* functions but using PDO as the backend.
Some of the reasons why mysql_* methods were removed were the lack of:
- Stored Procedures (can’t handle multiple result sets)
- Prepared Statements
- Encryption (SSL)
- Compression
- Full Charset support
- Security
My object uses PDO, so it can be modified if needed to include such features. For now the only reason why someone would use this object is to avoid rewriting their entire codebase and switch to MySQLi/Pdo/etc.
The object duplicates all exact functionality of mysql_* functions except for mysql_info method which I tried to duplicate as best as I can, but due to PDO limitations/my knowledge I can’t do it exact.
Feel free to use the object and post any issues you may find so that we can improve on it. Also let me know if you find any issues, bugs or see room for improvement.
Package is hosted on PHPClasses.org @
http://www.phpclasses.org/package/8221-PHP-Access-MySQL-databases-using-PDO-wrapper-functions.html
All files are public so you won’t need to register/login to view them (let me know if it is not the case and I’ll post it here).
Sample usage:
<?php // Include the definitions require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'MySQL_Definitions.php'); // Include the object require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'MySQL.php'); // Include the mysql_* functions require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'MySQL_Functions.php'); // Now all of the mysql_* methods will work on a PHP version that has them removed.