O'Reilly logo

CouchDB and PHP Web Development Beginner's Guide by Tim Juravich

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action — adjusting our get_posts_by_user function to skip and limit posts

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 called classes/post.php.
  2. Find our get_posts_by_user function, and add $skip with a default value of 0 and $limit with a default value of 10.
    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(); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required