PDO in the PHP database abstraction layer -- Introduction and installation configuration
Introduction
The PHP Data object (PDO) extension defines a lightweight consistent interface for PHP to access the database. Each database driver implementing the PDO interface can expose the features of a specific database as a standard extension function. Note that using PDO extension itself cannot implement any database functions; you must use the PDO driver of a specific database to access the database service.
PDO provides a data access abstraction layer, which means that no matter which database is used, the same function (method) can be used to query and obtain data. PDO does not provide the database abstraction layer; it does not overwrite SQL or simulate missing features. A mature abstraction layer should be used if necessary.
PDO has been attached since PHP 5.1 and used as a PECL extension in PHP 5.0. PDO requires new features of PHP 5 core, so it cannot run on earlier versions of PHP.
Install configurations
Install PDO on Unix systems
Since PHP 5.1.0, the PDO and PDO_SQLITE drivers are available by default. You must enable the POD driver for your selected database;
Note:
When building PDO with shared extensions (not recommended), all PDO drivers must be loaded after the PDO itself.
When you install PDO for a shared module, you need to update the php. ini file so that the PDO extension can be automatically loaded when PHP is running. You also need to enable specific database drivers there; make sure they are listed after the row pdo. so, because PDO must be initialized before the specific database extensions are loaded. Skip this step if PDO and specific database extensions are built statically.
extension=pdo.so
Windows environment
PDO and all major drivers are released as shared extensions along with PHP. to activate them, simply edit the php. ini file:
extension=php_pdo.dll
Note:
This step is not required in PHP 5.3 and later versions. for PDO, it is no longer necessary to use it as a DLL file.
Next, select the DLL file of another specific database, and then either load it with dl () at runtime or enable it after php_pdo.dll in php. ini. For example:
extension=php_pdo.dllextension=php_pdo_firebird.dllextension=php_pdo_informix.dllextension=php_pdo_mssql.dllextension=php_pdo_mysql.dllextension=php_pdo_oci.dllextension=php_pdo_oci8.dllextension=php_pdo_odbc.dllextension=php_pdo_pgsql.dllextension=php_pdo_sqlite.dll
The DLL files should exist in extension_dir of the system.
Note:
Remember: after changing the php. ini file, you must restart the PHP service to make the new configuration command take effect.