PHP only connects to Mysql?

Asked

Viewed 1,163 times

9

I’ve never seen PHP connect using other databases, like Oracle, for example. In Mysql, to connect, you use mysqli connect, what if it were in another? PHP is integratable with which database?

  • 2

    Has a number of banks, postgresql, sql server, oracle, odbc generic driver etc

5 answers

14


Almost all banks use their own protocols that run "under the TCP" generally, even if 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 quite laborious since it will have to understand the protocol of the specific bank.

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

http://php.net/manual/en/refs.database.php

Otherwise PHP also uses PDO which is a "standardized" API for different banks: http://php.net/manual/en/book.pdo.php

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

It is noteworthy that the mysql does not spin together with PHP, do not even need to be on the same server, mysql as other databases are usually in different locations (it depends on the type of database), it is important to understand this to understand the issue of a language supporting something, ie there is native stand and there is the possibility of writing something of its own or using a 3rdparty.

I myself once wrote a class for sending own SMTP and used a class 3rdparty for FTP instead of using the native functions (there was a bug on the server I used, in the version of PHP that was a bit old).

All the examples I mentioned are like most databases, they use a TCP (usually/always/? ), so I mean even if the language doesn’t support something natively yet yes it may be possible that there is an extension created by third parties (.dll in windows and .so in Unix-like) or even a script written in PHP that provides functionality to communicate with a type of database not natively supported.

Related:

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

npm install mysql
  • But isn’t phpmyadmin just a platform that uses Mysql? Or is Phpmyadmin also a database?

  • @Lucascarvalho The question is not quite this, I Linkei the question so that you can understand where PHP is and where Mysql, Phpmyadmin is not a bank, I left this very explicit in the answer of the question that Linkei, the "focus is": Note that mysql does not run together with PHP, they do not even need to be on the same server, which is the important point to understand why the issue of support for a database in PHP might be something extremely relative ;)

  • @Lucascarvalho edited the answer, I just wanted to highlight what the native Apis are and the issue of language and support, I hope it’s a little easier to understand.

12

Using the PDO library, it is possible to connect with 12 types of databases.

List:

  1. CUBRID
  2. MS SQL Server
  3. Firebird
  4. IBM
  5. Informix
  6. Mysql
  7. MS SQL Server
  8. Oracle
  9. ODBC and DB2
  10. Postgresql
  11. Sqlite
  12. 4D

For more information about using these connections you may be making the query in the official PDO documentation in PHP at http://php.net/manual/en/pdo.drivers.php

PDO is only one of the extensions to access database in Php, if you want to know other extensions you can see in http://php.net/manual/en/refs.database.php.

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 that works, you can probably use ODBC, that is not as good as native access.

Some extensions already come with PHP. It is true that Mysql is the most used, but it is common to use Sqlite, since it is simpler, usually has better performance, is very suitable for web, and as powerful as Mysql besides being up mis reliable. Others are:

Among other lesser known. A current full list can be seen in the documentation.

Whenever using a technology should be all its documentation. People only use a 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 needing to know the details, in general this has several disadvantages and the advantage that they offer is usually not required by the application. Of course abstraction can only access databases that it understands and that op PHP knows how to handle, even if through a third party extension.

If you have no reason, do not use PDO.

0

When we talk about database 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.

-1

Yes, PHP can connect to other databases like Oracle and so on, you just need to search the PHP documentation. Here are two examples

Browser other questions tagged

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