Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

when/where we use PDO?

I want to know when and where we use PDO's other than simple mysql_connect methods?

Is this PDO is faster ? what are the advantages over other methods?

like image 928
coderex Avatar asked Sep 22 '26 23:09

coderex


1 Answers

  1. Security: The most useful thing with PDO are the prepared statements. With them, writing code which can be SQL Injected is far more complicated. ;-)

  2. Errorhandling: On the other hand the errorhandling is much much better as you can switch to Exceptions instead of lousy FATALs ERRORs and so on.

  3. Extensibility: With the mysql_ methods you're strictly bound to mysql. Maybe sometime in the future you want to use antoher database and have to rewrite all your connection and query issuing code. If you're using MySQL specific queries this point has no value to you as you have to rewrite most of your database code anyway.

like image 77
Malax Avatar answered Sep 25 '26 15:09

Malax



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!