Aziz Saleh – Software development

  • Home
  • Downloads
    • AzizMVC Downloads
      • Database Plugin
        • Template Plugin
    • Flash Builder 4
      • Bypass, Hijack, Beat, and Defeat Same Origin Policy
      • Flash Click Tracker
      • Flash Link Hider
      • Pacman source V 1.0
    • Java Downloads
      • Currency Converter
    • Javascript Downloads
    • PHP/MySQL Downloads
      • Aziz MVC
      • AzizMVC Documentation
      • Contact Form Maker
      • NetFlix API 1.0 Wrapper
      • Simple Blog
    • Visual Basic Downloads
      • Currency Converter
        • Key Logger w/Store, email, registry options
  • Resume & Portfolio
  • Ask me a question
  • Contact Me

Posted on September 8, 2013 by Aziz Posted in MySQL, PHP

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.
mysql_connect mysql_query mysql_select_db undefined
« Checking if you have Javascript installed by PHP
Your PHP installation appears to be missing the MySQL extension which is required by WordPress »

Leave a comment Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • PHP does not have MySQL support enabled.
  • Your PHP installation appears to be missing the MySQL extension which is required by WordPress
  • Undefined mysql functions (mysql_connect, mysql_select_db, mysql_query) – PDO alternative
  • Checking if you have Javascript installed by PHP
  • Process Maxmind countries, regions and cities – Parser to MySQL or SqLite

Recent Comments

  • fathima on Currency Converter Using Java Netbeans
  • Chris on Currency Converter
  • Khalid Ahmad Qweder on Resume & Portfolio
  • Michel on Currency Converter
  • Michel on Currency Converter

Archives

  • March 2014
  • September 2013
  • November 2012
  • October 2012
  • November 2011
  • February 2011
  • December 2010
  • November 2010
  • August 2010
  • May 2010
  • September 2009

Categories

  • Flash Builder 4
  • General
  • Java
  • Javascript
  • MySQL
  • PHP
  • Visual Basic

Meta

  • Register
  • Log in
  • Entries RSS
  • Comments RSS
  • WordPress.org
CyberChimps ©2023