4 ms·
MySQL is deprecated and outright removed in PHP 5.5, so MySQLi is your fallback option instead. However, PDO is the best choice.
by trebor 12y ago
MySQL is deprecated and outright removed in PHP 5.5, so MySQLi is your fallback option instead. However, PDO is the best choice.
- byoung2 12y agoTo add to the above, PDO is a good choice if you will be working with different database technologies (either in this project or across different projects), you only have to learn one API. If you only need MySQL, mysqli does have a few more features than PDO. EDIT: here is a comparison: http://php.net/manual/en/mysqlinfo.api.choosing.php http://php.net/manual/en/mysqlinfo.api.choosing.php
- shire 12y agoSo mysqli is the best choice if I'm only working with MySQL? but PDO is good for other technologies? good to know. Thanks.
- byoung2 12y agoCorrect. PDO is great because one API works with many technologies. So today you're working with MySQL, but tomorrow you may be working with postgres, and the next day sqllite or MSSQL. It's nice to not have to relearn everything (sure each technology will still have quirks, but largely they work the same with PDO). That flexibility comes with a few limitations, because if one technology supports it and another doesn't, that defeats the whole "one API to rule them all" thing.
- shire 12y agoif I'm working for clients is best to use PDO for database access all the time?
- Someone1234 12y agoIt is best to use PDO unless you have a VERY good concrete reason not to. It is hard to even quantify what mysqli offers which PDO doesn't (because it is extremely niche). But it is very easy to quantify what PDO offers over mysqli (multi-database, flexibility, a better object model, etc). PDO has been around in the PHP world for a while now, it isn't going away. Specific database APIs are dying, and the performance gap which might have once existed has been closed. I wouldn't start a project in mysqli in 2014.
- jonnyynnoj 12y agoI'd always go with PDO, as its parameter binding is much more flexible/intuitive than mysqli's