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

Unlock the full course today

Join today to access over 22,700 courses taught by industry experts or purchase this course individually.

Build objects using record values

Build objects using record values - PHP Tutorial

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

Start my 1-month free trial

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 values. So in order to do that, what we want to do is take these…

Contents