In this chapter, we covered the foundations of working with databases in Yii2. By working with database access objects, we showed how we can execute raw SQL statements to run against our database and how we can use transactions to protect our database integrity. We also illustrated the use of Query Builder, which can enable us to write database-agnostic queries in a programmatic way. We then discovered how we can use Query Builder to construct intelligent data providers, which are used to supply data to reusable data widgets. Finally, we learned how to configure Yii2 to be aware of master-slave and multi-master database cluster configurations and how to load balance between these connections.
In the next chapter, we discover the capstone of working with databases in Yii2—Active Record—which is a powerful tool used to work with our data and model our database structure. We'll also dive into Active Records relatives, basic models, and forms, and we'll learn how we can use a powerful...