How mysqli different from mysql


Posted on 08 Jan 16 by Vickey

Mysqli extension is an improved version of Mysql. The 'i' in mysqli is for “improved”.In mysqli  many new features added. Here are some benefits of mysqli

1. Object-oriented interface

You can improve or change base mysqli class

class customSql extends mysqli {

2.Prepared Statements

It prevent SQL injections and execuation is faster then mysql

3. Multiple Statements

You can execuate multiple query in one mysqli call. This reduce the no of calls between database and the PHP server.

$connection = new mysqli($host, $user, $password, $database);
$query  = "INSERT INTO users (name,email ) VALUES('user name','');";
$query  .= "INSERT INTO employee (name,email ) VALUES('employee name','');";
$result = mysqli_multi_query($connection, $query);

4.Support for Transactions

Mysqli support transactions queries.  If there is an error in process in mysqli queries it will  rolled back all queries.

5.Enhanced debugging capabilities

By using "mysqli_debug()" we can write debugging information in a file

If this post help you reduce time to develop, you can help me to maintain this website :)