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.
Why
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.
So
PDO has appeared. It is an abstract data model (an abstract interface layer) that provides a common interface for accessing multiple databases.
Now
PHP connects to database with three different options
- MySQL Series functions: Native function Procedural style
- 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
- PDO: Extended, syntactically closer to mysqli (5.1 and above support)
Tips
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]
- The first thing to consider is efficiency.
If the project is demanding on operational efficiency, you should use MySQL or mysqli
- 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.
- 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.