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

Unlock this course with a free trial

Join today to access over 25,500 courses taught by industry experts.

Find a single record

Find a single record

- [Instructor] In the previous movie, we retrieved all bicycle records from the database and built new objects whose properties had those same values. In this movie, we're going to learn how to retrieve a single record from the database. This is very common, to want to be able to review all records and then also to be able to focus in on a single record. Let's switch over to our bicycle class and we already have find all. What I want to write now is another method, static public function, and it's going to be called find by ID. So the idea is that we're going to pass in the ID of the record that we want to it, and it's going to retrieve only that record. So let's start by writing the SQL that we're going to need. So I'll write SQL equals and this is also going to be a select all from bicycles. I'm going to put a space at the end, because I'm going to keep this line going. I'm going to just append it to a new line. And this…

Contents