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.

Find by username

Find by username - PHP Tutorial

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

Start my 1-month free trial

Find by username

- [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…

Contents