Learn how to define a class that can keep track of the key variables used for pagination and use them to calculate other important values.
- [Narrator] In this movie, we will define a new class…that can help us to keep track…of our pagination variables and calculations.…So let's create a new class.…This is going to go inside our classes directory.…Make a new file, and I'm going to call it pagination.class.php.…It will need some php tags, and it's going to be…a class definition for pagination.…So inside this class, we want to keep track…of the different properties.…
And we know that there are three main variables…we want to keep track of.…Public current page, public per page,…and public total count.…So the way that I think that we'll add…those properties in here is when we create…a new instance of the pagination,…we can just pass those in while we're creating it…and then it will set them.…So let's define a construct method that'll do that for us.…Public function__construct and then we'll pass in the page=1…and per page is going to default to 20 and $total_count=0.…
Okay, so then we have this current page, should get set to…the value of page, and I'm also going to make sure that…
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.