PHP PDO class solves database connection problem_PHP tutorial

WBOY
Release: 2016-07-15 13:33:41
Original
914 people have browsed it

For first time contact

POD extension is added in PHP5. This extension provides PHP PDO class to access the database. Different databases use the same method name, so solve The problem of inconsistent database connections.

The goal of the PHP PDO class

Provide a lightweight, clear, and convenient API
Unify the common features of various RDBMS libraries, but do not exclude more Advanced features.
Provides an optional greater degree of abstraction/compatibility via PHP scripts.

Features of PHP PDO classes:

Performance. PDO learned from the beginning about successes and failures in extending existing databases. Because PDO's code is brand new, we have the opportunity to redesign performance from the ground up to take advantage of PHP 5's latest features.
Ability. PDO is designed to provide common database functionality as a foundation while providing easy access to the unique features of an RDBMS.
Simple. PDO is designed to make working with databases easy for you. The API doesn't force its way into your code and makes it clear what each function call does.
Extensible at runtime. The PDO extension is modular, enabling you to load drivers for your database backend at runtime without having to recompile or reinstall the entire PHP program. For example, the PDO_OCI extension implements the oracle database API instead of the PDO extension. There are also drivers for MySQL, PostgreSQL, ODBC, and Firebird, with more in development. [separator]

Install PHP PDO class

This is a PDO extension for development under WINDOWS. If you want to install and configure it under Linux, please go elsewhere Find.

Version requirements: php5.1 and later versions are already included in the package; php5.0.x needs to be downloaded from pecl.php.net and placed in your extension library, which is the file where PHP is located folder; the manual says that versions before 5.0 cannot run PDO extensions.

Configuration:

Modify your php.ini configuration file so that it supports pdo. (If you don’t understand php.ini, you need to figure it out first. Modify the php.ini displayed when calling your phpinfo() function) and remove the semicolon in front of extension=php_pdo.dll, which is the php configuration file comment symbol. This extension is necessary. Further down there are

;extension=php_pdo.dll
;extension=php_pdo_firebird.dll
;extension=php_pdo_informix.dll
;extension=php_pdo_mssql.dll
;extension=php_pdo_mysql .dll
;extension=php_pdo_oci.dll
;extension=php_pdo_oci8.dll
;extension=php_pdo_odbc.dll
;extension=php_pdo_pgsql.dll
;extension=php_pdo_sqlite.dll

The databases corresponding to the PHP PDO class extension are:

Driver name Supported databases
PDO_DBLIB FreeTDS / Microsoft SQL Server / Sybase
PDO_FIREBIRD Firebird/Interbase 6
PDO_INFORMIX IBM Informix Dynamic Server
PDO_MYSQL MySQL 3.x/4.x
PDO_OCI Oracle Call Interface
PDO_ODBC ODBC v3 (IBM DB2, unixODBC and win32 ODBC)
PDO_PGSQL PostgreSQL
PDO_SQLITE SQLite 3 and SQLite 2

Which database you want to use, just remove the comment symbol ";" before the corresponding extension.


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/446026.htmlTechArticleFor the first time, the POD extension was added in PHP5. This extension provides the PHP PDO class to access the database. Different The database uses the same method name to solve the problem of inconsistent database connections...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!