General Discussion Using PHP with MySQL Connecting PHP to MySQL Handling Exceptions

Edmunds Sulzanoks
Edmunds Sulzanoks
5,828 Points

MySQL Improved Extension

So my hosting provider uses cPanel and I couldn't find a mySQL port number. But whle trying to find it I saw this in mysql server info tab "PHP extension: mysqli". After checking it out I found out that it stands for "MySQL Improved Extension" (wierd abbreviation) and that I should open DB connection like this:

$db=mysqli_connect('localhost','db_name','password','username');

seems a more efficient way. Is this something all recent mysql versions support or do you need to have a special "PHP extention" installed?

1 Answer

Edmunds Sulzanoks
Edmunds Sulzanoks
5,828 Points

Found answer.

The core advantage of PDO over MySQLi is in its database driver support. At the time of this writing, PDO supports 12 different drivers, opposed to MySQLi, which supports MySQL only. In situations when you have to switch your project to use another database, PDO makes the process transparent. So all you'll have to do is change the connection string and a few queries - if they use any methods which aren't supported by your new database. With MySQLi, you will need to rewrite every chunk of code - queries included.