MySQLi Introduction

MySQLi (or simply known as MySQL Improved) is a relational database management system used in the PHP programming language to give an interface with MySQL databases. It is reliable for both small and large applications and included with PHP versions 5 and later.

There are three main API options when considering connecting to a MySQL database server:

  • PHP's MySQL Extension
  • PHP's MySQLi Extension
  • PHP Data Objects (PDO)

MySQLi is improved version of MySQL. Before MySQLi we were using its old version MySQL and millions number of projects have been developed using PHP and MySQL and later PHP announce their ideas to deprecate MySQL extension in 2011. Officially MySQL has been removed from PHP 5.5

The MySQLi extension provides various benefits with respect to its predecessor, the key enhancements over the mysql extension being:

  • Object-oriented interface
  • Support for Prepared Statements
  • Support for Multiple Statements
  • Support for Transactions
  • Enhanced debugging capabilities
  • Embedded server support

Note: If you are using MySQL versions 4.1.3 or later it is strongly recommended that you use this extension.

As well as the object-oriented interface the extension also provides a procedural interface. The mysqli extension is built using the PHP extension framework, its source code is located in the directory ext/mysqli.

Below the Comparison of Features:

The following table compares the functionality of the three main methods of connecting to MySQL from PHP

PHP's MySQLi Extension PDO PHP's MySQL Extension
PHP version introduced 5.0 5.0 pre-3.0
Included with PHP 5.x Yes Yes Yes
Included with PHP 7.x Yes Yes No
MySQL development status Active development Active development as of PHP 5.3 Deprecated as of PHP 5.5
Removed in PHP 7.0
Recommended by MySQL for new projects Yes - preferred option Yes No
API supports Charsets Yes Yes No
API supports server-side Prepared Statements Yes Yes No
API supports client-side Prepared Statements No Yes No
API supports Stored Procedures Yes Yes No
API supports Multiple Statements Yes Most No
Supports all MySQL 4.1+ functionality Yes Most No