Does PHP only connect to MySQL?

9

I've never seen PHP connect using other databases, such as Oracle for example. In MySQL, to connect, is mysqli connect used, and if it was in another? PHP is integrable with which database?

    
asked by anonymous 23.06.2017 / 18:35

5 answers

14

Almost all banks use their own protocols that run "under the TCP that PHP does not have a native API for a specific type of bank, it is possible to write something of its own, of course it is very laborious since you will have to understand the specific bank protocol.

In addition to mysql there are other banks supported natively by PHP, it follows the list of supported banks (usually it is necessary to activate an extension):

link

Otherwise PHP also uses PDO which is a "standardized" API for different banks: link

a>

  

Note: I will not list all banks, because this is something that can change, so I leave the official documentation link, so it is easier to keep track of what has been discontinued and new media. / p>

Note that mysql does not run together with PHP , do not need to be on the same server, mysql as other banks are usually in different places (depends on the type of database), it is important to understand this to understand the issue of a language to support something, ie exists < strong> native support and there is the possibility to write something of your own or use a 3rdparty .

I myself once wrote a class for sending SMTP itself and used a 3rdparty class for FTP rather than using the native functions (there was a bug on the server I used in the PHP version which was a bit old).

All of the examples I've cited are like most databases, they use communication by TCP a> (usually / always /?), so I mean even if the language does not support something natively yet it may be possible that there is an extension created by third parties ( .dll in windows and .so in unix-like) even a script written in PHP that provides functionality to communicate with a type of bank not supported natively.

Related:

This explanation of communication "language vs. bank" is something that can be "applied" to some other languages / technologies, an example of another technology is Node.js , where they do not see native support for banks, but you can install via NPM , for example install mysql:

npm install mysql
    
23.06.2017 / 18:42
12

Using the PDO library, you can connect to 12 types of databases.

  

List:

  • CUBRID
  • MS SQL Server
  • Firebird
  • IBM
  • Informix
  • MySQL
  • MS SQL Server
  • Oracle
  • ODBC and DB2
  • PostgreSQL
  • SQLite
  • 4D
  • For more information on using these connections you may be consulting the official PDO documentation in PHP at link

    The PDO is only one of the extensions to access database in Php, if you want to know other extensions can consult in link .

        
    23.06.2017 / 18:40
    10

    In theory it can be integrated with any database. In general the connection is made through an extension to the database. And when none of this works, you can probably use ODBC , which is not as good as native access.

    Some extensions already come along with PHP. It's true that MySQL is the most commonly used, but it's common to use SQLite , since it is simpler, usually has better performance, is very suitable for web, and as powerful as MySQL in addition to being up to mis trustworthy. Others are:

    Among others less known. A current full list can be seen in the documentation .

    Whenever you use a technology it should be all your documentation. People use only one database because it has become popular, and it has become popular because people only use what is popular.

    It is possible to use some abstraction to access several databases without having to know the details, this usually has several disadvantages and the advantage they normally offer is not required by the application. Of course the abstraction can only access banks that it understands and that op PHP knows to manipulate, even though through a third party extension.

    If you have no reason, do not use PDO.

        
    23.06.2017 / 18:38
    0

    When we talk about database 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 / 14:20
    -1

    Yes, PHP can connect to other databases like Oracle and etc., you simply search the documentation pertaining to PHP. Here are two examples

    23.06.2017 / 18:38