Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

Why PDO and not MYSQLI?

If i look around in internet in reading about how to use mysql in php every time i am reading best to use mysqli and in comparison mysqli is much more powerfull. Why here mysql is always approached by PDO?

Why using PDO than Mysqli :

  • I would say that first of all it's a question of taste.
  • No need to learn several API unless you want to use specific tools from each API.
  • All DBMS will have prepared query, even SQLITE but PDO has the ability to emulate the PHP side rather than SQL side.
  • The interface is clear and minimalist, no fetch_assoc just a fetch function to which we pass an argument.
  • No nightmare between "procedural / Object Oriented ", as there is only an Oriented Object API version.
  • Finally ... :) Great ease of configuration through the setAttribute.

Hope it helped you making a choice :) Have a great day !

1 Answer

Alena Holligan
STAFF
Alena Holligan
Treehouse Teacher

PDO can be used with multiple databases, not just MySQL