PDO introduction [does not include specific use methods]

Source: Internet
Author: User
In fact

PHP support for the database is not good, the most important point is that there is not enough abstraction, the access interface is not unified.


PHP has a separate module, a set of independent functions for each database. This structure and design makes it difficult for PHP to be compatible with multiple databases.
Once you move an app to another database environment, or add a new database, you'll need to rewrite the database-related operations.


PDO has appeared. It is an abstract data model (an abstract interface layer) that provides a common interface for accessing multiple databases.


PHP connects to database with three different options

    1. MySQL Series functions: Native function Procedural style
    2. MYSQLI Series functions: Extensions, enhancements to MySQL series functions, API for programming and object-oriented two styles, new features such as precompilation and parameter binding
    3. PDO: Extended, syntactically closer to mysqli (5.1 and above support)


The PDO extension is just an abstraction of the interface layer, and using the PDO extension itself does not implement any database operations, it must use a specific database PDO driver to access the database.

PDO efficiency issues

Since PDO has so many features, should you not use PDO right away?
[The following conclusions are based on the 5.3 test procedure omitted]

    1. The first thing to consider is efficiency.
      If the project is demanding on operational efficiency, you should use MySQL or mysqli
    2. Load aspects
      Depending on the number of user tests, PDO has a long connection load higher than MySQL direct and is more stable, another user test, PDO connection MySQL, Oracle speed than direct Connect has advantages.
    3. Will the app be migrated to another database?
      In practical application, 90% of the application is not the database migration, the necessity is not big.

In summary, even in Oracle, precompilation and parameter binding do not necessarily speed up, but are likely to be inefficient because of changes in execution plans. Some database precompilation can result in inefficiencies. It is recommended to try PDO in a new application, and the old application does not need to be refactored.

[This view is excerpted from a book]

'). addclass (' pre-numbering '). Hide (); $ (this). addclass (' has-numbering '). Parent (). append ($numbering); for (i = 1; i <= lines; i++) {$numbering. Append ($ ('
  • '). Text (i)); }; $numbering. FadeIn (1700); }); });

    The above describes the PDO introduction [not including specific use methods], including aspects of the content, I hope to be interested in PHP tutorial friends helpful.

  • Related Article

    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.