Home >Backend Development >PHP Problem >How to open pdo in php

How to open pdo in php

(*-*)浩
(*-*)浩Original
2019-09-20 10:37:264648browse

PDO (PHP Data Object) The extension was added in PHP5. PDO will be used by default to connect to the database in PHP6. All non-PDO extensions will be removed from the extension in PHP6.

How to open pdo in php

This extension provides PHP built-in class PDO to access the database. Different databases use the same method name to solve the problem of inconsistent database connections.

The goal of PDO is to provide a lightweight, clear, and convenient API that unifies the common features of various RDBMS libraries, but does not exclude more advanced features.

Provides an optional greater degree of abstraction/compatibility via PHP scripts. (Recommended learning: PHP programming from entry to proficiency)

Features of PDO: Performance. PDO learned from the beginning about the successes and failures of scaling existing databases. Because PDO's code is brand new, we have the opportunity to redesign performance from the ground up to take advantage of the latest features of PHP 5.

PDO is designed to provide common database functionality as a foundation while providing easy access to the unique features of an RDBMS.

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.

The PDO extension is modular, enabling you to load drivers for your database backend at runtime without having to recompile or reinstall your 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.

In the Windows environment of PHP 5.1 and above, the pdo and main database drivers are released together with PHP as extensions. To activate them, you only need to simply edit the php.ini file.

Open the php.ini configuration file, find extension=php_pdo.dll (configure the php configuration file, enable the corresponding extension) and extension=php_pdo_mysql.dll (enable the extension to the corresponding database, take MySQL as an example), and remove them In the previous ";" comment, the modified two-line configuration content is as follows:

extension=php_pdo.dll
extension=php_pdo_mysql.dll

Finally, restart apache

You can see the detailed information of the PDO extension by viewing phpinfo

<?php
phpinfo();

Run it and search for pdo. If you can see the information as shown in the picture, it means the connection is successful. You can use

How to open pdo in php

The above is the detailed content of How to open pdo in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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