MySQLi or MySQL Improved Extension, as the name implies, is an improved version of the conventional PHP MySQL driver, offering some extra benefits. Previously we wrote the basics on MySQL in What is MySQL, Why We Need MySQL.
MySQLi Basics
It is actually not possible to provide every details on MySQLi on this website. This is beyond the scope of this website. Our purpose is to provide the basic idea about any inquiry that might arise either in need or out of curiousness. That is what this website is for, what ever the topic is. If you are looking for titbits on MySQLi, then please consult php.net for the official reference. Common questions around MySQLi are (from various comments) :
- Why we will use MySQLi instead of MySQL?
- Are there situations where one should not use MySQLi?
- Do server needs to be configured differently to use MySQLi?
MySQLi is object oriented, it enables most of the features of MySQL. MySQLi delivers prepared statements, transactions, multiple statements and possibly it is a safer way of exchanging data or running commands to the MySQL server and in turn it protects from SQL injection. This might be a reason for choosing MySQLi over MySQL. It is said that, the MySQL version 4.1.3 or later users must use the mysqli extension. Unfortunately, some functions are not yet included in MySQLi.
---
Notes on MySQLi
It depends on the blogging software or CMS, whether it will support MySQLi or not. While many PHP MySQL CMS has started to offer MySQLi connectivity; like MyBB forum software; many including WordPress, does not have MySQLi support enabled out of the box. In that case, we need to modify the PHP codes manually. WordPress uses mysql_* functions.
When the question is around upgrading to MySQLi from MySQL, for long term, PDO seems to be superior over MySQLi. This is why people usually compares MySQLi with PDO, not MySQL versus MySQLi.
Some references are given below :
1 | http://php.net/manual/en/book.mysqli.php |
1 | http://php.net/manual/en/class.mysqli.php |
1 | http://net.tutsplus.com/tutorials/php/why-you-should-be-using-phps-pdo-for-database-access/ |