Learn how to begin creating an active record class by specifying which database the class should use for its connections.
- [Instructor] I want to start implementing…the active record design pattern…by first telling our object about the database connection…that it should be using.…In the code that we've already implemented…where we're using a database connection,…you can see right here that we're calling…database query.…So this is just simply inside a PHP file.…This is not inside a class.…What I want to do is I want to be able…to move queries like this inside my class,…and to do that I need to tell the bicycle class…about the database connection.…Now I could come over here to my bicycle class…and I could do something like use global…in order to bring in that variable…so that we could use it inside our class.…
But that's not ideal for a couple of reasons.…It means that every time I have a method…that's going to use the database,…I have to first remember to tell that method…to bring in the database variable from the global scope.…A better approach is just to tell this class…about its database connection.…So we can just simply have a variable called public database…
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.