Advantages of pdo over mysql_ * or mysqli_ *

I noticed that many people use or migrate to pdo, I have never used it before, and I really didn’t want to change it, I still haven't changed, but I would like to know from people who use pdo every day why I should move on to this, I mean, what advantages does it have over mysql_ * or mysqli_ *, I talked a lot about this, but have not yet found a satisfactory answer. Thanks

+5
source share
3 answers

It does not support multiple databases with a single application (although you can, with caution). This does not make it easier to change databases in the future (although this helps). It is that one consistent, reasonable interface is used regardless of the database. This not only helps programmers (more widely applying their skills) and projects (simplifying the transition of programmers), but also greatly simplifies the creation of libraries that are located at one level above the level of data access. Perl has had DBI for 20 years, and that was very good. PDO is a very similar concept (in fact, it steals at least half of the DBI).

+2
source

PDO aims to maintain transparent access to various forms of SQL databases. This is the so-called "data access abstraction layer" for PHP.

SQL99, ;).

PDO , . dor PDO, , PHP - PDO.

:

  • PDO PHP .
  • SQL99, ,
  • PDO - , .
0

PDO simplifies migration between two different DBMSs. Some people also use it for applications that support all the DBMSs supported by PDO. But note that this is usually the wrong practice: if you do not know the software very well, you should not tell your users that you support it because you are lying - because you cannot solve problems with real life.

mysqli is not an abstraction. This is a fast and reliable api for MySQL and should be the first choice.

-1
source

All Articles