Differences

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)

Recommended Tutorials for you


Tags

Anuj kumar

This is Anuj Kumar. I’m a professional web developer with 5+ years of experience. I write blogs in my free time. I love to learn new technologies and share with others. I founded PHPGurukul in September 2015. The main aim of this website to provide PHP, Jquery, MySQL, PHP Oops and other web development tutorials. .

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Back to top button
Close
Close