What is MySQLi? What does it do?
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
I always recommend to open database connection by using object oriented way because it is very faster, secure and efficient.
- $db = new mysqli('host', 'user', 'password', 'database');
- if($db->connect_errno > 0){
- die('Error : ('. $db->connect_errno .') '. $db->connect_error);
- }
It is helpful for those user who want to switch to MySQLi from old MySQL because it is much similar to MySQL.
- $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 .
- MySQLi Prepared Statements - Insert Value in database table
- Insert Multiple Value in database table
- PHP MySQLi prepared statement select multiple rows
0 comments:
Post a Comment