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,129 This week: 5All time: 273 This week: 18Up
Version License PHP version Categories
mydql2i 1.6Public Domain5PHP 5, Databases
Description 

Author

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
Winner


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: 58
All time rank: 618 in United States United States
Week rank: 11 Up3 in United States United States Up
Innovation award
Innovation award
Nominee: 32x

Winner: 7x

Recommendations

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

Example

<?php
 
/*
  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.
  */
 
include_once('mysql2i.class.php');
?>


Details

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 readme.md Doc. Additional Information

 Version Control Unique User Downloads Download Rankings  
 0%
Total:7,129
This week:5
All time:273
This week:18Up
User Ratings User Comments (14)
 All time
Utility:98%StarStarStarStarStar
Consistency:95%StarStarStarStarStar
Documentation:88%StarStarStarStarStar
Examples:89%StarStarStarStarStar
Tests:-
Videos:-
Overall:76%StarStarStarStar
Rank:64
 
very good one
4 years ago (chap man)
80%StarStarStarStarStar
Really a great class for emergency cases! Thanks Dave
4 years ago (Mauro)
77%StarStarStarStar
Thank you so much for this package! My host decided to upgrad...
4 years ago (Ron Gaba)
80%StarStarStarStarStar
Thank you! One minor change, in mysql2i.
5 years ago (Manuel Guzman)
80%StarStarStarStarStar
Very usefull package.
6 years ago (zinsou A.A.E.Moïse)
77%StarStarStarStar
Worked on an old piece of complex rats nest coding very well
6 years ago (jon washtell)
80%StarStarStarStarStar
Perfect!
7 years ago (Pedro Garcia)
80%StarStarStarStarStar
nice
7 years ago (muabshir)
80%StarStarStarStarStar
Thanks a lot for this code!!
7 years ago (Thierry Lemaire)
72%StarStarStarStar
Thanks for your great work.
7 years ago (Paco Perez)
80%StarStarStarStarStar
"does what is says on the tin" thanks.
8 years ago (Fred Mac Donald)
80%StarStarStarStarStar
Excellent support by the author
8 years ago (Heinz Ernst)
65%StarStarStarStar
Great and very useful! Thank you for sharing this.
8 years ago (Terry Woody)
80%StarStarStarStarStar
Thanks for the class, its really useful.
8 years ago (Saahisht Paul)
70%StarStarStarStar