I have been searching the internet and I know that MySQL for database connection as such is deprecated since Php 7.0.0 and MySQLi should be used as a replacement.
However, I have the big question: does this also cover the PDO part for MySQL?
I read on php.net about PDO MySQL and it doesn't mention that it is obsolete, but when dealing with the same connection to a database, the doubt remains.
If not obsolete, could it be discontinued in the near future? Is it advisable to continue using it or for new projects I use everything with MySQLi?
Short answer
As much
MySQLi
asPDO
they are totally valid for new projects.We can deduce it from what is stated here:
Feature Comparison
The Manual offers the following comparison table, in which we can see that as much
PDO
as theymysqli
are valid to use them in any current project. The comparison also includes extensionmysql_*
1 , which is deprecated and not recommended for future projects. This extension no longer comes in PHP 7 core.Comparison between PDO, mysqli and mysql in the PHP Manual
1 The current state of the extension
mysql_*
was covered in this question: Why shouldn't the mysql_* API be used in PHP/MySQL? . Its use still appears in many code examples on the net... and it also appears a lot in questions posed on SO, so it is important to always underline the obsolescence of this extension, which is also often confused withmysqli
.