1. What is PDO?
PDO stands for PHP Data Objects. It is an interface for accessing database in PHP (Hypertext Preprocessor). PDO is a class and built-in available to PHP5. PDO supports multiple database access.
PDO - PHP Data Objects - Introduction |
To access database server, we have to provide database-specific PDO driver. Following are database names that implement the PDO interface:
- Cubrid
- FreeTDS / Microsoft SQL Server / Sybase
- Firebird
- IBM DB2
- IBM Infomix Dynamic Server
- MySQL 3.x/4.x/5.x
- Oracle Call Interface
- ODBC v3 (IBM DB2, unixODBC and win32 ODBC)
- Postgre SQL
- SQLite3 and SQLite2
- Microsoft SQL Server / SQL Azure
- 4D
print_r(PDO::getAvailableDrivers());
2. Features of PDO
There are following some features of PHP Data Objects:
- Supports 12 different drivers
- Supports Named parameters
- Supports Prepared Statements
- Security
3. Advantages of PDO
There are many advantages of PDO. Some of them are listed below:
- PDO supports 12 different drivers
- Object Oriented Programming
- Easy to connect with server
- Supports Named parameters and Prepared statements
- Supports stored procedures
- Light-weight
- Well organized code and easy to read
- Built-in available to PHP5 and lateral
- It is secure
- Easy to write code
4. Disadvantages of PDO
If we compare PDO with MySQLi and case of speed of execution then MySQLi wins.
Conclusion:
There are many advantages of PDO. In short we can say that there is no disadvantages of PDO. Decide which is more suitable for you? PDO or MySQLi. I recommend PDO.
Which API are you using PDO or MySQLi? Please Comment below.
Does PDO protect against sql injection?
ReplyDeleteit does if you bind the parameters correctly
DeleteUse Prepared statements in PDO. It protects from SQL Injection
ReplyDelete