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 — adding support to delete posts in our application

Now that we have access to the _rev variable in our base class, let's add support so that our application can delete posts from the user profile.

  1. Let's start by opening classes/post.php and adding a line of code to the get_posts_by_user function so that we have _rev available to us.
    public function get_posts_by_user($username) {
    $bones = new Bones();
    $posts = array();
    foreach $bones->couch- >get('_design/application/_view/posts_by_user?key="' . $username . '"&descending=true&reduce=false')->body->rows as $_post) {
    $post = new Post();
    $post->_id = $_post->value->_id;
    $post->_rev = $_post->value->_rev;
    
    $post->date_created = $_post->value->date_created;
    
  2. Next, let's create a nice ...

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