Posts

PDO vs. MySQLi: With PHP Database APIs

Image
Introduction The mysql_ extension is no longer supported as of PHP 7, and its methods have been deprecated since PHP 5.5. Unfortunately, there are still a tonne of outdated tutorials on the internet that newbies will simply copy and paste and use on a shared hosting platform with an outdated PHP version, perpetuating its legacy. You can select either MySQLi or PDO if your PHP application uses MySQL or MariaDB. The latter is an abstraction layer that enables you to use a unified API for all 12 database drivers it supports, whilst the former is only an enhanced version with procedural and OOP support and added prepared statements. However, it should be noted that MySQL is unquestionably the most widely used database in the PHP community. Theoretically, the conversation ought to be finished. Since using a single database type is so much easier, we don't require vendor-specific APIs for each form of database that exists. While there is undoubtedly much truth in this, PDO MYSQL just lac...