Learn how to add validation code before an admin record is saved to the database and how to make some validations conditional on the object's state.
- [Instructor] In this movie,…we'll talk about how to add validations…to our admin class in an object-oriented way.…You'll recall that in the last chapter,…we gave our DatabaseObject class a method called validate…and it just has a real skeleton of a method there,…just sets errors equal to nothing,…and then returns those errors.…What we need to do is add custom validations…to the admin class that inherits from DatabaseObject.…So, in admin.class.php,…we want to add a new method down here…which is also going to be the same type of method,…protected function called validate,…and it's going to override that behavior…with its own behavior.…
I've included that in the exercise files for you.…Let's open that file up.…You can take all of these lines…from protected function validate down to the bottom,…and make sure I get that final curly brace.…Let's copy all of that and let's go into admin…and let's paste it in.…Now, these validations are the exact same validations…that we talked about…in the PHP with MySQL essential training.…
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.