Does php have to be connected to mysql? cannot oracle or sqlserver?

Source: Internet
Author: User
Tags sql server driver sybase
Does php have to be connected to mysql? cannot oracle or sqlserver? Does php have to be connected to mysql? cannot oracle or SQL server?

Reply content:

Does php have to be connected to mysql? cannot oracle or SQL server?

PHP extensions for various database systems (MySQL/SQLite/PostgreSQL/Oracle/SQL Server)

Three major MySQL connection methods in PHP (the underlying implementation of the driver started from 5.4 is mysqlnd ):
Mysqli (preferred) pdo_mysql (recommended) mysql (not recommended)
PHP has built-in MySQL driver mysqlnd since 5.4:

php-src/ext/mysqlnd/php-src/ext/mysql/php-src/ext/mysqli/php-src/ext/pdo_mysql/

Link: mysql, mysqli, and pdo_mysql. the underlying programming interfaces for operating MySQL in PHP depend on the MySQL driver mysqlnd built in PHP.

To be compatible with multiple databases, the framework prefers PDO.
However, PHP programs dedicated to MySQL management, such as phpMyAdmin, use MySQL to support better MySQL.

In PHP5.3, mysqlnd support is enabled as follows:

--with-mysql=mysqlnd--with-mysqli=mysqlnd--with-pdo-mysql=mysqlnd

If it is left blank after PHP5.4, mysqlnd: is enabled by default:

--with-mysql--with-mysqli--with-pdo-mysql

PHP7 is not supported at the beginning -- with-mysql.

SQLite:
-- With-sqlite3 is enabled by default.
-- With-pdo-sqlite is enabled by default and depends on -- with-sqlite3. we recommend pdo_sqlite to operate SQLite.

The ext Directory of the Windows binary package contains the following extensions:

php_mysql.dllphp_mysqli.dllphp_pdo_mysql.dllphp_sqlite3.dllphp_pdo_sqlite.dll

Debian/Ubuntu software package: php5-mysqlnd php5-sqlite

PostgreSQL Driver for PHP:

--with-pgsql=DIR--with-pdo-pgsql=DIRDIR is the PostgreSQL base install directory or the path to pg_config.

Debian/Ubuntu software package: php5-pgsql
apt-cache depends php5-pgsqlWe can see that it depends on the PostgreSQL C client library libpq5.
The development kit libpq-dev contains/usr/bin/pg_config.

sudo apt-get install libpq-dev--with-pgsql=/usr/bin/pg_config--with-pdo-pgsql=/usr/bin/pg_config

Oracle Driver for PHP:

-- With-oci8 = DIR -- with-pdo-oci = DIR this extension is experimental. DIR defaults to $ ORACLE_HOME.

You can also install the Oracle Instant Client and specify the following parameters:

--with-oci8=shared,instantclient,/usr/lib/oracle/11.2/client/lib--with-pdo-oci=shared,instantclient,/usr/lib/oracle,11.2

Oracle Instant Client (60 MB ):
Http://www.oracle.com/technet...
Php_oci8.dll
Php_oci8_11g.dll
Php_pdo_oci.dll

SQL Server Driver for PHP (php_sqlsrv.dll and php_pdo_sqlsrv.dll, Windows only ):
Http://www.microsoft.com/en-u...

FreeTDS: The driver used to connect SQL Server and Sybase in UNIX/Linux.
-- With-pdo-dblib = dir pdo: DBLIB-DB support. DIR is the FreeTDS home directory
UnixODBC is a data source manager that manages data source names created by various data drivers.
FreeTDS is a free SQL Server/Sybase driver in UNIX/Linux systems,
You can create a data source name by using unixODBC to access the data.

UnixODBC Supports ODBC in Linux, but it is only an ODBC manager,
To connect to the actual database, you must provide the ODBC driver for the database.
FreeTDS is a free ODBC driver used in Linux to connect SQL Server and Sybase.
Install unixODBC and FreeTDS first.

IODBC is an ODBC database connection implementation in UNIX/Linux. Similar projects include unixODBC.

--with-iodbc--with-pdo-odbc=iODBC,/usr/local--with-unixODBC--with-pdo-odbc=unixODBC,/usr/local

Related packages on Ubuntu/Debian:

php5-odbc - ODBC module for php5php5-sybase - Sybase / MS SQL Server module for php5/usr/lib/php5/20121212/mssql.so/usr/lib/php5/20121212/pdo_dblib.so

Of course, it must be OK.

Php can be said to use any database on the market, but their mysql combination is the most efficient, just like php can use iis or apache. in contrast, apache is highly efficient, and nginx is later introduced, which is more efficient.

Use pdo for adaptation without worrying about any databases

Of course it's not necessary to connect to mysql.

Mainly depends on your needs

PHP has PDO and has abstracted the specific DB Driver. of course, other databases can.

Good PDO methods

It can only be said that MySQL is currently the most widely used and is open-source and free. many other common databases can be used.

PHP and MYSQL are prime partners, but not only mysql is supported. you can use PDO to operate various databases.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.