Working with Databases
Content of the «Working with Databases» section:
- Database Access Objects: Connecting to a database, basic queries, transactions, and schema manipulation
- Query Builder: Querying the database using a simple abstraction layer
- Active Record: The Active Record ORM, retrieving and manipulating records, and defining relations
- Migrations: Apply version control to your databases in a team development environment
Articles section «Working with Databases»:
Elasticsearch Extension provides the elasticsearch integration for the Yii2 framework. It includes basic querying/search support and also implements the ActiveRecord pattern that allows you to store active records in elasticsearch.
Redis extension Yii2 provides the redis key-value store support for the framework. Redis includes a Cache and Session storage handler and implements the ActiveRecord pattern that allows you to store active records in redis.
Sphinx Extension for Yii 2 adds Sphinx full text search engine extension for the Yii 2 framework. It supports all Sphinx features including Real-time Indexes.
During the course of developing and maintaining a database-driven Yii 2 application, the structure of the database being used evolves just like the source code does. Steps show how database migration can be used by a team during development Yii 2 application.
Active Record provides in Yii 2 an object-oriented interface for accessing and manipulating data stored in databases. An Active Record class Yii is associated with a database table, an Active Record instance corresponds to a row of that table, and an attribute of an Active Record instance represents the value of a particular column in that row.
Built on top of Database Access Objects, Yii 2 query builder allows you to construct a SQL query in a programmatic and DBMS-agnostic way. Compared to writing raw SQL statements, using Yii query builder will help you write more readable SQL-related code and generate more secure SQL statements.
Built on top of PDO, Yii DAO (Database Access Objects) provides an object-oriented API for accessing relational databases. When using Yii DAO, you mainly need to deal with plain SQLs and PHP arrays.