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 - PHP Tutorial
From the course: PHP: Object-Oriented Programming with Databases
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
(Locked)
CRUD operations5m 59s
-
Create a record9m 35s
-
(Locked)
Dynamic attribute list7m 59s
-
(Locked)
Sanitize values for database4m 40s
-
(Locked)
Find record to update8m 34s
-
(Locked)
Update a record11m 30s
-
(Locked)
HTML forms for OOP5m 38s
-
(Locked)
Validations and errors8m 22s
-
(Locked)
Delete a record7m 21s
-
(Locked)
Create inheritable code11m 12s
-
(Locked)
-
-
-