Disclaimer: this question is strictly about mysql and database abstraction layers that support it.
The PHP website notes that using the mysql_ functions of PHP is highlighy discouraged. It instead encourages developers to use PDO or MySQLi.
Here’s my question: in regards to mysql, under all the abstraction, are PDO and MySQLi just being a safer, more object-oriented wrapper for the mysql_ functions?
And if that’s true, aren’t frameworks like CodeIgniter and Symfony creating an unnecessary amount of wrappage by putting a layer on top of MySQLi which would then put a layer on top of native PHP mysql_?
If it isn’t true, I want to know why an experienced developer is discouraged from using mysql_ and what PDO and MySQLi actually do under the abstraction.
(Also, please don’t tell me to go look at the code) Will give +100 bounty.
No. Like xdazz said, both MySQLi and PDO are implemented in C, which means they don’t just wrap the mysql_* functions.
There’s another reason to consider: CodeIgniter and Symfony probably created an interface over the default interface, because the default interface isn’t usable enough (from their point of view). I myself have written a layer over PDO which sets some default settings (such as error-mode, as PDO is quiet by default) and makes a more intuitive API altogether. PDO is a very decent piece of software, but the
setAttribute( $attr, $value )just isn’t my cup of tea, really.