MySQL ExtensionThis was the first method PHP provided to interact with MySQL. This extension provides a set of built-in functions for connecting and making database queries. If a PHP built-in function starts with term mysql, it’s a function of this extension. For example, the following is the function used for connecting to MySQL.
mysql_connect('hostname', 'username', 'password');MySQL extension only supports features of MySQL versions prior to 4.1.3. You can’t use advanced features of MySQL like Prepared Statements that was introduced after MySQL version 5 with this extension. But since many PHP applications only need to execute CRUD operations, you will still see functions of this extension in use. As of PHP version 5.3, there is no further development in this extension and it is only maintained.
MySQL Improved (MySQLi) ExtensionThis is the recommended method for executing MySQL operations in PHP. MySQLi supports basic and advanced MySQL features. It’s available from PHP version 5. MySQLi provides two interfaces to interact with MySQL: Procedural Interface and Objected Oriented Interface.
MySQLi Procedural InterfaceThis interface provides built-in functions like MySQL Extension. If a PHP built-in function starts with term mysqli, it’s a function of this interface. Below is how you need to connect with MySQL via this interface.
mysqli_connect('hostname', 'username', 'password');
MySQLi Objected Oriented InterfaceThis interface allows instantiation of an instance of built-in class mysqli. After instantiating an instance properly, the instance will have methods and properties to interact with MySQL. Below is how you instantiate an instance of mysqli.
$mysqli = new mysqli('hostname', 'username', 'password');