0

I'm reading up on php db classes and everything i'm reading recommends "PDO". Cool. So what then is the purpose of "mysqli_stmt"? Is is deprecated?

Please advise.

sleeper.

sleeper
  • 3,446
  • 7
  • 33
  • 50
  • possible duplicate of mydqli or PDO pros and cons http://stackoverflow.com/questions/13569/mysqli-or-pdo-what-are-the-pros-and-cons – Yamiko May 09 '12 at 19:57
  • @yamikoWebs. Agreed. I searched, but maybe my search criteria wasn't specific enough. – sleeper May 09 '12 at 20:08
  • `PDO` and `mysqli` both use a low-level library created for communication with MySQL. They basically use the same low level code, but they expose a different API to the programmer. Whether you use one or another, you are, in fact, calling the same code essentially. `PDO` is, in my opinion, much easier to use and as stated in the answers, with `PDO` you have the same API that can *speak* multiple RDBMS "languages", keeping the API the same. The purpose in using `mysqli` would be that you prefer `mysqli` for some reason (or you have a legacy app that's been developed with `mysqli`). – N.B. May 09 '12 at 20:22

3 Answers3

2

There is more than one way to do things. PDO is a database layer that allows you to use many different database types via various drivers. mysqli_* is only for MySQL.

Both will get the job done when using a MySQL database. I recommend PDO, but that is just my preference, as I like the flexability of possibly changing databases more easily in the future.

Brad
  • 159,648
  • 54
  • 349
  • 530
2

Mysqli is said to be the faster performance wise of the two, however the features of PDO far outweigh those of Mysqli in my opinion. I also prefer the flexibility of PDO when changing databases.

Darren Burgess
  • 4,200
  • 6
  • 27
  • 43
2

PDO is an abstraction layer, mysqli is an extension that interacts directly with the database.

WWW
  • 9,734
  • 1
  • 29
  • 33