Duplicate: mysqli or PDO - what are the pros and cons?
I'm looking to move a website from mysql to either mysqli or pdo as primarily a learning tool, but also for performance increases if possible.
I have read through http://php.net/manual/en/mysqli.overview.php and it seems like both would suit my needs, but it doesn't lean strongly either way.
The site currently uses primarily non object orientated code, but I do have experience with OO in other languages. A huge majority of the queries are simple complex select statements with very little update/inserts. What do you suggest as being the most useful both from my own education and for this specific site?
If you need any additional information please let me know.
Thanks.
PDO Pro's:
Mysqli Con's:
Otherwise, both libraries are basically different flavors of the same thing. They both have functions to quote parameters and both support parameterized queries.
If none of the above arguments sway you, then go with whichever library you prefer based on its syntax, style, etc.
I don't believe PDO would give you any performance increase, but it gives you these two very attractive long-term benefits:
If you don't understand the benefits to #1 and #2, then just stick with the tried-and-true mysql library (you are at least using mysql_real_escape_string though, right)?
If I were learning a new PHP database library, I believe PDO is the way to go, especially if you are creating a web app that may be used on a variety of systems other than your own server.
From http://www.php.net/manual/en/mysqli.overview.php :
While PDO has its advantages, such as a clean, simple, portable API, its main disadvantage is that it doesn't allow you to use all of the advanced features that are available in the latest versions of MySQL server. For example, PDO does not allow you to use MySQL's support for Multiple Statements.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With