Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Advantages of pdo over mysql_* or mysqli_* [duplicate]

Tags:

php

mysql

pdo

I have noticed that a lot of people are using or migrating to pdo, I have never used that before and I was really reluctant to change to that, I still have not changed anyway, but I would like to know from people who use the pdo everyday why I should change to that, I mean what advantages does it have over mysql_* or mysqli_*, I have googled a lot about that but I have not found a satisfactory answer yet. Thanks

like image 524
James Okpe George Avatar asked Nov 12 '22 06:11

James Okpe George


1 Answers

It's not about supporting multiple databases with one app (although you can, with care). It's not about making it easy to change databases in the future (although it helps). It's about having one consistent, sensible interface to use regardless of database. Not only does that benefit programmers (by making their skills more broadly applicable) and projects (by making it easier for programmers to jump in), it also makes it a lot easier to create libraries that sit one layer above the data access layer. Perl has had the DBI for 20 years and it's been a decidedly good thing. PDO is a very similar concept (in fact it steals at least half of DBI's interface).

like image 131
hobbs Avatar answered Nov 15 '22 06:11

hobbs