Learn how to define a find_by_username method and use it to write a validation to ensure that an admin's username property is unique before it can be saved.
- [Narrator] In this movie, we're going to learn…how to find admin records using the Username column,…and then use that as a validation to confirm that a…username is unique before we accept it into the database.…We already have a validation function placeholder for this,…go to our validation functions.php.…There's has unique username, and that's what we…had before when we were working in php with mySQL…essential training.…But we need to now rewrite that…using object oriented programming.…So, let's think about how we would do that.…
The first thing we need to do,…is we need to get an admin, and we would do that…by asking the adman to return a user to us.…So we would need to have admin class and then…find the user, so we can't use Find all,…and we can't use find by ID,…we're going to need to write a new one,…which is find by username.…And we'll need to pass in the username that's been…sent in to this validation,…so that we can then pass that on to the class…and see if we find this user by username,…do we get a user back or not.…
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.