& Amp; nbsp; what is the database abstraction layer? You only need to understand the role of the database abstraction layer. the database abstraction layer can be easily transferred when you switch from one database to another without modifying too much code. Use the database abstraction layer to simplify the code
What is the database abstraction layer? You only need to understand the role of the database abstraction layer. the database abstraction layer can be easily transferred when you switch from one database to another without modifying too much code. With the database abstraction layer, the code is more standardized and the efficiency is greatly improved! Common Database abstraction layers include ADODB, PHPLi, and PDO. today we will talk about the application of PDO!
The benefits of PDO are Needless to say. compared with mysql and mysqli function libraries, PDO makes cross-database usage more friendly; compared with ADODB, PDO is more efficient.
I believe everyone will use php5.0 and later versions. Congratulations! the php package already comes with PDO. But you still need to open the extension in php. ini!
Extension = php_pdo.dll
Extension = php_pdo_mysql.dll
Extension = php_pdo_pgsql.dll
Extension = php_pdo_sqlite.dll
Extension = php_pdo_mssql.dll
Extension = php_pdo_odbc.dll
Extension = php_pdo_firebird.dll
Extension = php_pdo_oci8.dll
The above extensions correspond to different Database Drivers. which Database do you use? just remove the previous extensions. I use mysql.
PDO connection database:
The php Tutorial is as follows:
True); // use try .. catch check connection successful try {foreach ($ db-> query ('select * from user') as $ row) {print_r ($ row) ;}$ db = null; // Close the database} catch (PDOException $ e) {echo $ e-> getMessage () ;}?>
The above php code uses common queries and can be queried in other ways!
In the next article, we will introduce in detail various usage methods of PDO!