PDO and mysqli are the only options to work with PHP database?

Asked

Viewed 222 times

-4

And if I needed to use a database that wasn’t supported by PDO, what I could do?

After all, what does PDO do underneath the scenes? It uses mysqli?

2 answers

3

The PDO uses the native mechanisms of databases to access them. PDO is just an extra layer that provides little or no advantage over the original mechanism. Surely there is the downside of the extra layer.

Except for the fact that most people use the PDO without knowing why, they just want to use what’s fashionable, they use it so that one day they can exchange databases. Something that usually never happens and when it happens, the person discovers that it doesn’t work that simple, even becomes compatible, but it doesn’t mean that it gets good performance.

It is possible to have other Mysql providers, but I don’t see anyone using.

It is possible to use any database that has a vendor, even if it is not standard PHP. There is a asks which list what is default.

It is possible to use ODBC, but in practice it will only do this if there is no other way. It is best to always look for native access to the database. Of course the database should be able to communicate with ODBC. In general if the bank is worth always have a native access.

There are other modules that try to abstract the access as the PDO, but do not succeed. I’m not sure why, but people don’t use it because they don’t solve a problem that isn’t solved by other solutions.

1


When we talk about data bandwidth extensions PHP, according to the documentation, there are two distinct groups:

  1. The layers of abstractions, and;
  2. Vendor-specific database extensions.

Referring to the abstraction layers the documentation cites four types of layers, that is, four representations of connection between PHP and a database server, are they:

  1. DBA - Database (dbm-style) Abstraction Layer

    DBA: These are functions that create the basis for accessing Berkeley DB-style databases. This is a general abstraction layer for various file-based databases. As such, the functionality is limited to a common subset of features supported by modern databases such as »Oracle Berkeley DB.

  2. DBX

    DBX: The dbx module is an abstract database layer (db 'X', where 'X' is the supported database). The dbx functions allow you to access all supported databases using a single call convention. The dbx-functions themselves do not act directly with the databases, but rather on the modules that are used to support this database.

  3. ODBC

    ODBC: In addition to normal ODBC support, the Unified ODBC functions in PHP allow you to access various databases that have lent ODBC API semantics to implement your own API. Instead of maintaining multiple database drivers that are all virtually identical, these drivers have been unified into a single set of ODBC functions. The following databases are supported by the Unified OBDC functions: » Adabas D, » IBM DB2, » iODBC, » Solid, and » Sybase SQL Anywhere.

  4. PDO - PHP Data Objects

    PDO: Each database driver that implements the PDO interface can expose database-specific features as regular extension functions. Note that you cannot perform any database function using the PDO extension alone; you must use a database-specific PDO driver to access a database server. PDO provides a data access abstraction layer, which means that regardless of the database you are using, you use the same functions to send queries and search for data. PDO does not provide a database abstraction; it does not rewrite SQL or simulate missing resources. You should use a full abstraction layer if you need this facility. PDO is provided with PHP 5.1 and is available as a PECL extension for PHP 5.0; PDO requires the new OO features in the PHP 5 core and therefore will not run with previous versions of PHP.

About the vendor-specific database extensions, the documentation cites 23 types and because they are too extensive I believe it is better to take a look at the link provided at the beginning of the answer.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.