What is MySQLi? What does it do?

What is MySQLi? What does it do?

In this post we will give you information about What is MySQLi? What does it do?. Hear we will give you detail about What is MySQLi? What does it do?And how to use it also give you demo for it if it is necessary.

MySQLi is improved version of MySQL. Before MySQLi we were using its old version MySQL and millions number of projects have been developed using PHP and MySQL and later PHP announce their ideas to deprecate MySQL extension in 2011. Officially MySQL has been removed from PHP 5.5

MySQLi database system is relaible for both small and large applications.

MySQLi is open source relational database management system which is used on web.

MySQL must not be used in new development anymore.

Old extension does not support Prepared Statements and improved version of MySQL (MySQLi) and PDO that support Prepared Statements are object oriented.

For security reasons, you must use Prepared Statements. Its very important for your web application security.

By using Prepared Statements, you can protect your application from SQL injection.

MySQLi support for multiple statements and enhance debugging capabilities.

For MySQLi installation, click here :
http://php.net/manual/en/mysqli.installation.php

You can connect your application to database by two ways :

  • Connection with the object oriented way
  • Connection with the procedural way

Connection with the object oriented way

I always recommend to open database connection by using object oriented way because it is very faster, secure and efficient.

  1. $db = new mysqli('host','user','password','database');
  2. if($db->connect_errno >){
  3. die('Error : ('. $db->connect_errno .') '. $db->connect_error);
  4. }
$db = new mysqli('host', 'user', 'password', 'database');

if($db->connect_errno > 0){
    die('Error : ('. $db->connect_errno .') '. $db->connect_error);
}

Connection with the procedural way

It is helpful for those user who want to switch to MySQLi from old MySQL because it is much similar to MySQL.

  1. $db = mysqli_connect('host','user','password','database');
  2. // check connection
  3. if(mysqli_connect_errno()) {
  4. trigger_error('Database connection failed: '. mysqli_connect_error(), E_USER_ERROR);
  5. }
$db =  mysqli_connect('host','user','password','database');
// check connection
if (mysqli_connect_errno()) {
  trigger_error('Database connection failed: '  . mysqli_connect_error(), E_USER_ERROR);
}

PHP MySqli Basic usage :

Now i will show you the basic usage of MySQLi, such as select, insert, update and delete records. I hope this list will help you in developing application .

  1. MySQLi Prepared Statements – Insert Value in database table
  2. Insert Multiple Value in database table
  3. PHP MySQLi prepared statement select multiple rows

MySQLi is going very popular database system used with PHP

Hope this code and post will helped you for implement What is MySQLi? What does it do?. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

Leave a Comment

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

7  +  2  =  

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US