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-pgsql
We 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.