What is the use of pdo? Solution

Source: Internet
Author: User
What is the use of pdo? In the Encyclopedia, the PDO extension defines a lightweight and consistent interface for PHP to access the database. It provides a data access abstraction layer so that no matter what database is used, you can use consistent functions to query and obtain data. PDO is released with PHP5.1. what is the use of pdo in the PECL extension of PHP5.0?
Encyclopedia
The PDO extension defines a lightweight and consistent interface for PHP to access the database. It provides a data access abstraction layer so that no matter what database is used, you can use consistent functions to query and obtain data. PDO is released with PHP5.1 and can also be used in the PECL extension of PHP5.0.

What does this mean? Can the query code executed with pdo run normally even if the database is changed?
SQL queries vary with data. for example, if mysql has limit and MSSQL does not have limit, will pdo be automatically converted?
If not, what is the significance of using pdo? Php extension
------ Solution --------------------
Due to database differences, the calls of different databases are not exactly the same. if the same program uses different databases to store data, you need to modify the data processing part of the program, causing inconvenience to the transplantation.
Using pdo provides consistent interfaces for database access. you only need to configure different database drivers in the configured connection parameters, and minimize the changes to the data processing program, you don't even need to change it. It brings great convenience for data processing and security.
------ Solution --------------------
Reference:
No other extensions are required.

In the past, each type of database had to be extended, and now it is not needed.



In fact, it cannot be said that it has no dependency with other packages.

After php5.3, php adds a library named mysqlnd. pdo_mysql will judge that if the macro PDO_USE_MYSQLND is defined, mysql will be operated using the api provided by mysqlnd, otherwise, he needs to know the installation directory of your mysql and go to the mysql installation directory. H file, and then call the mysql api.

There are also php_mysql and php_mysqli. if you specify the mysql driver as mysqlnd (-- with-mysql = mysqlnd and -- with-mysqli = mysqlnd) during php compilation ), you can use the mysqlnd interface to operate mysql. Otherwise, you need to specify -- with-mysql and -- with-mysqli as php-config and use the mysql api.


Php_pdo_mysql_int.h
--------------------------------
/* $ Id $ */

# Ifndef PHP_PDO_MYSQL_INT_H
# Define PHP_PDO_MYSQL_INT_H

# If defined (PDO_USE_MYSQLND)
# Include "ext/mysqlnd. h"
# Include "ext/mysqlnd/mysqlnd_libmysql_compat.h"
# Define PDO_MYSQL_PARAM_BIND MYSQLND_PARAM_BIND
# Else
# Include
# Define PDO_MYSQL_PARAM_BIND MYSQL_BIND
# Endif

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.