PHP Classes

PHP MySQL to MySQLi: Replace mysql functions using the mysqli extension

Recommend this page to a friend!
  Info   View files Example   View files View files (4)   DownloadInstall with Composer Download .zip   Reputation   Support forum (40)   Blog (3)    
Ratings Unique User Downloads Download Rankings
StarStarStarStar 76%Total: 7,169 This week: 3All time: 269 This week: 22Up
Version License PHP version Categories
mydql2i 1.6Public Domain5PHP 5, Databases


This class can replace the mysql functions using the mysqli extension.

It provides equivalent functions that perform the same operations as the mysql extension when this is not available.

An auxiliary script is provided to provide global functions with the same names and parameters as mysql extension functions except that they call the class to use the mysqli extension.

Innovation Award
PHP Programming Innovation award winner
June 2015

Prize: One downloadable copy of PhpED Professional
The original MySQL extension is being deprecated and will be removed from the core starting from PHP 7.

There is a lot of legacy applications that need to be updated to either move to mysqli or PDO extensions so they can work on PHP 7.

However, this process is not always trivial, as it is not just a matter of replacing the names of functions that are called.

This package provides a quick replacement of the mysql extension functions that use the mysqli extension functions instead. This way the legacy application can continue to work on PHP 7 or later with minimal changes.

Manuel Lemos
Picture of Dave Smith
  Performance   Level  
Name: Dave Smith is available for providing paid consulting. Contact Dave Smith .
Classes: 51 packages by
Country: United States United States
Age: 59
All time rank: 608 in United States United States
Week rank: 17 Up1 in United States United States Up
Innovation award
Innovation award
Nominee: 32x

Winner: 7x


php8 myqsl_pconnect
xampp php 8 mysql_pconnect not working

PDO Class
I need a class to connect to my db (mysql). Now my code is a old

PHP MySQL to MySQLi: Replace mysql functions using the mysqli ex
how to Replace mysql with MySQLi functions using the mysqli

Mysql 2 msqli
How to use msqli on mysql scripts

Best PHP mysql to mysqli or PDO solution
How to convert mysql code to use mysqli?

mysql to mysqli
looking for mysql2i


  The mysql2i class is intened to provide seemless cross over when new versions of PHP,
  which no longer have the mysql extension, are installed. This is a temporary stop gap
  measure to allow developers time to update their code to mysqli or PDO::mysql extensions.
  The mysql2i class is a drop and go replacement for the PHP mysql extension. It uses a
  mysqli wrapper to handle mysql function calls.
  Place the mysql2i.class.php and mysql2i.func.php files in a web accessible folder and
  include the mysql2i.class.php file before any mysql function calls a made, usually from
  within your initialization files.
  The mysql2i.class.php file will include the functions file when the mysql extension is
  not found, so this class can be included anytime, even in installations where the mysql
  extension still exists.


The problem

PHP has deprecated the mysql extension which will be removed in PHP 7. Even though it was recommended to use the improved extension, mysqli, many developers continued to use mysql.

The effect

Once PHP 7 is released in mid November of this year, 2015, many hosted servers will upgrade and scripts still relying on the old mysql extension will fail.

There are lot of web sites using legacy packages that are no longer supported by the developer and not all developers have had time to update their current packages to the improved mysqli extension.

The solution

The PHP mysql to mysqli package was developed to be the stop gap to keep everything working smoothly.

It can be placed in any PHP script, at anytime, and when the mysql extension disappears, it will take over. It works by defining functions using the old mysql function names and passing the arguments to the class methods that will use the improved mysqli extension.

  Files folder image Files  
File Role Description
Accessible without login Plain text file example.php Example Example Usage
Plain text file mysql2i.class.php Class Main Class
Accessible without login Plain text file mysql2i.func.php Aux. Functions
Accessible without login Plain text file Doc. Additional Information

 Version Control Unique User Downloads Download Rankings  
This week:3
All time:269
This week:22Up
User Ratings User Comments (14)
 All time
very good one
4 years ago (chap man)
Really a great class for emergency cases! Thanks Dave
4 years ago (Mauro)
Thank you so much for this package! My host decided to upgrad...
4 years ago (Ron Gaba)
Thank you! One minor change, in mysql2i.
5 years ago (Manuel Guzman)
Very usefull package.
6 years ago (zinsou A.A.E.Mo´se)
Worked on an old piece of complex rats nest coding very well
6 years ago (jon washtell)
7 years ago (Pedro Garcia)
7 years ago (muabshir)
Thanks a lot for this code!!
8 years ago (Thierry Lemaire)
Thanks for your great work.
8 years ago (Paco Perez)
"does what is says on the tin" thanks.
8 years ago (Fred Mac Donald)
Excellent support by the author
8 years ago (Heinz Ernst)
Great and very useful! Thank you for sharing this.
8 years ago (Terry Woody)
Thanks for the class, its really useful.
9 years ago (Saahisht Paul)