PDO and mysqli are the only options for working with database in PHP? [duplicate]

-4

And if I needed to use a database that was not supported by the PDO, what could I do?

After all, what does the PDO do underneath the cloths? Does it use mysqli?

    
asked by anonymous 11.07.2017 / 00:34

2 answers

1

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

  • The layers of abstractions, e;
  • Provider-specific database extensions.
  • Regarding the layers of abstractions, the documentation mentions four types of layers, that is, they are four connection representations between PHP and a database server:

  • DBA - Database (dbm-style) Abstraction Layer

      

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

  • DBX

      

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

  • ODBC

      

    ODBC: In addition to normal ODBC support, the Unified ODBC functions in PHP allow you to access multiple databases that have borrowed the semantics of the ODBC API to implement their own API. Rather than 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 Unified OBDC functions: »Adabas D,» IBM DB2, »iODBC,» Solid, and »Sybase SQL Anywhere.

  • 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 can not perform any database functions by using the PDO extension by itself; You must use a database-specific PDO driver to access a database server. The PDO provides a layer of data access abstraction, which means that regardless of the database you are using, you use the same functions to issue queries and fetch data. The 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. The PDO comes with PHP 5.1 and is available as a PECL extension for PHP 5.0; The PDO requires the new OO features at the core of PHP 5 and therefore will not run with earlier versions of PHP.

  • For vendor-specific database extensions, the documentation mentions 23 types and because they are too long I think it's best to take a look at the link provided at the beginning of the response.

        
    11.07.2017 / 13:11
    3

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

    Except for the fact that most people use the PDO without knowing why, they just want to use what is fashionable, they use it so that one day they can change databases. Something that usually does not occur and when it occurs, the person discovers that it does not work as simple as this, until it is compatible, but does not mean that it performs well.

    It is possible to have other MySQL providers, but I do not see anyone using it.

    You can use any database that has a vendor, even if it is not PHP standard. There is a question that lists what is standard .

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

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

        
    11.07.2017 / 06:24