MySQL vs MySQLi

MySQL and MySQLi are PHP database extensions implemented by using the PHP extension framework. PHP database extensions are used to write PHP code for accessing the database.

MySQL extension is deprecated and will not be available in future PHP versions. It is recommended to use the MySQLi extension with PHP 5.5 and above.

MYSQLiMYSQL
MySQLi extension added in PHP 5.5MySQL extension added in PHP version 2.0
Extension directory: ext/mysqli.Extension directory: ext/mysql
The MySQLi supports prepared statements.The MYSQL does not support prepared statements.
MySQLi supports transactions through API.Transactions are handled by SQL queries only.
MySQLi provides both object-oriented and procedural interfaces.MySQL provides procedural interface.
MySQLi extension is with enhanced security and improved debugging.MySQL extension lags in security and other special features, comparatively.
MySQL provides a procedural interface.MySQLi provides both object oriented and procedural interface.
MySQLi supports store procedure.MySQL extension does not support stored procedure.
mysqli_connect($host_name,$user_name,$passwd,$dbname)mysql_connect($host_name,$user_name,$passwd) followed by
mysql_select_db($dbname)

Two of the mysqli functions:

mysqli_connect(connection information);
mysqli_query($con,"SQL statement");

The corresponding mysql functions are:

mysql_connect(connection information);
mysql_query("SQL statement",$con);

The connection process for mysql functions requires two function calls:

mysql_connect($host_name,$user_name,$password);
mysql_select_db($dbname);
mysqli Functionmysql Function
mysqli_real_escape_string($conn,$data)mysql_real_escape_string($data)
mysqli_errno($con)mysql_errno() or mysql_errno($cxn)
mysqli_select_db($con,$dbname)mysql_select_db($dbname)
mysqli_error($con)mysql_error() or mysql_error($con)
mysqli_query($con,$sql)mysql_query($sql) or mysql_query($sql,$con)
mysqli_fetch_array($result)mysql_fetch_array($result)
mysqli_num_rows($result)mysql_num_rows($result)
mysqli_fetch_assoc($result)mysql_fetch_assoc($result)
mysqli_fetch_row($result)mysql_fetch_row($result)
mysqli_insert_id($con)mysql_insert_id($con)
Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More

Privacy & Cookies Policy