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

Unlock the full course today

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

Dynamic attribute list

Dynamic attribute list - PHP Tutorial

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

Start my 1-month free trial

Dynamic attribute list

- [Instructor] In the previous movie, we learned to create a new record using an existing PHP object. In this movie, we're going to learn how we can improve that process by creating a dynamic list of the attributes. The part of the code that I want us to focus on is right here where we're listing off all of the different columns that are in the database and then going through and listing by hand each and every one of the properties that we want to assign to those columns. We could do this and it does work, but there are a couple of problems with it. The first is that I'm eventually going to want to make this code reusable. That's one of our goals later on is to make this code reusable for any database class that we have. It doesn't matter whether it's bicycles, whether it's administrators or customers, we should be able to have some reusable code that's able to just create a record in the database regardless of what columns it might have. So I want to create something that's a little…

Contents