Now that we know what to do, let's jump right into editing our classes/post.php
file and adjusting our get_posts_by_user
function so that we can add $skip
and $limit
as arguments.
1. Open the
Post
class by opening the file calledclasses/post.php
.2. Find our
get_posts_by_user
function, and add$skip
with a default value of0
and$limit
with a default value of10
.public function get_posts_by_user($username, $skip = 0, $limit = 10) { $bones = new Bones(); $posts = array(); ... }
3. Update our
get
call to Sag so that it passes the value of$skip
and$limit
into the query.public function get_posts_by_user($username, $skip = 0, $limit = 10) { $bones = new Bones(); $posts = array(); foreach ($bones->couch-> get('_design/application/_view/posts_by_user?key="' . $username . '"&descending=true&reduce=false&skip=' . $skip . '&limit=' . $limit)->body->rows as $_post) { ... }
4. Now that...