From the course: PHP: Object-Oriented Programming with Databases

Unlock this course with a free trial

Join today to access over 25,500 courses taught by industry experts.

Build objects using record values

Build objects using record values

- [Instructor] In this movie, we're going to learn to build objects using the values that we pull back from records in the database. This is the first part of the active record process. Database records are retrieved, which we've already done, but then their values are going to be used to populate the properties of objects. And this process needs to happen automatically. That's why it's called active record. It feels like there's an active relationship between the database data and our object. So as soon as we pull those values back, we want to immediately populate a new instance of bicycle with them. At the moment, we don't have the active record pattern. What we have is a result set, and then we're able to go through and fetch associative arrays out of that result set, which we can then use. Instead, what we want is for find_all to return an array of objects to us, objects that are already populated with the correct…

Contents