What is PHP Data Objects

W

PDO, an acronym for PHP Data Objects, is a PHP extension that can be used as an abstraction level for the connection between PHP programs and various databases.

PHP Data Objects (PDO) is a PHP extension that defines a light, consistent interface for accessing PHP databases.

Each database driver, which implements the PDO interface, can expose database-specific features through common expansion functions.

Note that you cannot perform operations with the database using only the PDO extension;

For this, you need to use a specific PDO driver to access the database server.

PDO provides an abstraction level for accessing data, which means no matter which database you use, you’ll use the same features to send queries and receive data. PDO does not provide an abstraction of the database.

It does not rewrite SQL, nor does it emulate missing features in some databases. For that, you should use a fully developed abstraction layer to get this feature.

From the PHP 5.1 PDO version is integrated with PHP and is available as PECL extension for PHP 5.0.

PHP was originally used to produce dynamic web pages now is widely used and in the development of web pages and web applications.

It is mainly embedded in HTML, but starting with version 4.3.0, it can also be used in the “command line” (CLI) mode, allowing for the creation of independent applications.

It is one of the most important open source and server-side programming languages, with versions available for most web servers and all operating systems.

Why use DOP?

1. Portability. It works with several DBMS (MySQL, PostgreSQL, SQLite, Oracle, Microsoft SQL Server).
2. Flexibility. If I used PDO in a project and I want to change the SGBD, I can do that by changing a single line of code.
3. Speed. PDO is a C/C ++ library, compiled language, not interpreted like PHP.

PDO can work with the following types of databases:

MySQL
PostgreSQL
SQLite 2 & 3
Firebird
Informix (IBM Informix Dynamic Server)
ODBC
Oracle
DBLM: FreeTDS / Sybase / MS-SQL
IBM (IBM DB2)

One of the advantages of PDO is that similar functions are used to query and process databases, regardless of their type (of the above mentioned).
Scripts that use the PDO interface to connect to the database typically perform the following operations:

1. Log in to the database server by calling new PDO (), obtaining an object to work with that database.
2. Application of specific PDO functions for Querying the database.
3. Retrieve and process retrieved data.
4. Disconnect from the server.

To see if your PDO is valid for your database, you can check with phpinfo, where is a PDO section.
When you want to connect to the MySQL PHP database, you have three ways to use: MySQL, MySQLi or PHP Database Object (PHP Database Object).

Recent Posts

Archives

Categories