In this current tutorial we will study how to connect PHP and MySQLi but before that we will study what is MySQLi extension in PHP.In this current tutorial we will study how to connect PHP and MySQLi but before that we will study what is MySQLi extension in PHP.
MySQLi Extension in PHP:
The mysqli extension, also known as MySql improved, is an improved extension of PHP. It is developed to use the new features included in MySql 4.1.3 or later. PHP version 5 has included this extension.
There are number of advantages of are present in this extension, few of those are it supports prepared statements, multiple statements, transactions, object oriented interface and this provides a procedural interface etc.
In PHP 5.3 persistent connection for mysqli was included With the help of persistent connection a connection between a client process and a database can be reused by the process. The advantage of this type of connection is we need not to connect to the database again and again, the unused connections are cached and can be reused.
In myqli there is no function for opening persistent connections. In mysqli we must put a p: before the hostname to open the connection. One of the major drawback of persistent connection is that it can be left in unpredictable state. The persistent connection of the mysqli extension has cleanup handling code, and it has so many features like rollback active transactions, close and drop temporary tables, unlock tables etc.