Create a dynamic list of attributes instead of hardcoding column names. This change makes the code more reusable and simplifies the conversion of properties into an SQL statement.
- [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 more flexible.…The other thing is we're going to be reusing these again…
Note: This is an intermediate-level training course that assumes you have existing knowledge of PHP. To refresh your skills, check out PHP Essential Training and PHP: Object-Oriented Programming.
- Creating a project database and tables
- Connecting to the database
- Database queries with OOP
- The active record design pattern
- Defining a database-driven class
- Performing common database tasks with OOP
- Creating inheritable and reusable code
- Object-oriented user authentication
- Object-oriented pagination
Skill Level Intermediate
Consuming RESTful APIs in PHP with Guzzlewith Justin Yost2h 12m Intermediate
PHP: Accessing Databases with PDO and MySQLiwith David Powers3h 47m Intermediate
1. Overview and Project Setup
2. The Database Connection
3. Define a Database-Driven Class
4. Object-Oriented CRUD
5. Object-Oriented Authentication
6. Object-Oriented Pagination
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.