YII provides powerful database programming support.
The Yii data Access Object (DAO) is built on the PHP data object (PDO) extension, making it possible to access different database management systems (DBMS) in a single unified interface. Applications developed using Yii DAO can easily switch between using different database management systems without having to modify the data access code.
The active record (AR) of YII implements a widely used object-relational mapping (ORM) approach to further simplify database programming. By convention, a class represents a table, and an instance represents a row of data. Yii AR eliminates the repetitive tasks of most SQL statements used to handle CRUD (create, read, update, and delete) data operations.
Although Yii DAO and AR can handle almost all database-related tasks, you can still use your own database library in Yii application. In fact, the YII framework is well-designed so that it can be used concurrently with other Third-party libraries.
The data interfaces supported by the YII framework are mainly three of the following:
Active Record
Query Builder
DAO
The sample database used in this tutorial is
Chinook database, the sample library, which is the famous Northwind databases, is currently supported by the following data types:
DB2
Effiproz
Mysql
Oracle
PostgreSQL
SQL Server
SQL Server Compact
Sqlite
Its data model is:
This tutorial is mainly used in MySQL, mainly because of the database type used with PHP with the most MySQL, so you need to install the MySQL database, the YII framework to support a variety of database types, support these database access interface is basically similar, so although this tutorial using MySQL as an example, The knowledge used also applies to other database types.
See a full set of tutorials: http://www.bianceng.cn/webkf/PHP/201301/35265.htm