Learn how to define query methods that can execute any SQL query and find all records in a table.
- [Instructor] Now that our bicycle class…knows what database connection it should use,…we're ready to start defining query methods…on the bicycle class.…In the previous movie,…we used that database connection…inside the bicycle class to execute a query.…What I want to do now is move that query inside the class.…The reason why is that it makes sense…that a bicycle class ought to know how…to retrieve all of the bicycles…that are stored in the database.…So what we essentially want…to do is move these two lines into our class.…
So I'm just going to copy those two lines,…and what I want to have instead here…is I just want to be able to call find all, right?…If I just call find all on the bicycle class,…it ought to be able to turn back a result to me.…Now notice that I'm calling this as a class method,…not an instance method.…I don't have an instance of bicycle.…I haven't found any yet.…I'm telling the class that it should use find all.…All right, so let's save that.…Remember, I already copied those lines that we were missing.…
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?
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.