R
R
Ruslan Khoroshkevich2013-09-22 11:21:56
PHP
Ruslan Khoroshkevich, 2013-09-22 11:21:56

MySQLi vs PDO - what to choose?

Hello!
I recently came across an article .
And after reading it, there was an ambivalent feeling. It seems like accessing MySQL via PDO is true, but at the same time, the author talks about some problems and expresses his “phi” of some code redundancy. At the same time, recommending to use the library for working with the mysqli API . Either ready, or if not too lazy - write your own.
Question to knowledgeable people: how important is it to switch to PDO? Especially when you consider that there is a kind of library where it is easy to replace the call through mysqli with the call through PDO.

Answer the question

In order to leave comments, you need to log in

6 answer(s)
V
Vyacheslav Plisko, 2013-09-22
@Zezst

PDO and mysqli are two very different things. PDO is a universal DBAL that allows you to work with any supported database.
mysqli is a highly specialized driver, thanks to which you can use all the advantages, it supports multi-queries, binds data more honestly, and allows you to collect statistics.
if you are going to use other databases, then it makes sense to use PDO, and that's it. you will have to supplement it with a qveri builder to get real portability. otherwise use mysqli which provides more functionality.

O
OnYourLips, 2013-09-22
@OnYourLips

If the question is “how relevant”, then it is important to use the tools for working with the database that are in the framework you are using.
If you are not using the framework, then I advise you to start doing it.

A
Artur Bordenyuk, 2013-09-22
@HighQuality

If something is working as it should, should it be changed? mysqli and PDO do a good job (don't forget that mysqli also has an oo interface).

E
EugeneOZ, 2013-09-22
@EugeneOZ

PDO. In a strange way, you understood the author - there is no recommendation to write your own version, there is only criticism of mysqli and recommendations on how to get around PDO restrictions. Of course, there could be less whining (all problems are related only to placeholders and they are all solvable).
The code you write now will need to be maintained in the future. And in the future, PDO will get more development, not mysqli.

F
FanatPHP, 2013-10-14
@FanatPHP

I think it's pretty clear there.
If we plan to use or write DBAL to work with Mysql, then mysqli.
If you can’t get rid of the habit of accessing API functions directly, then only PDO, since this library partially implements DBAL functions, and the developer will never need most of the subtleties implemented in mysqli.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question