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 for $_rev to our classes

Up until this point, we've seen the _rev key in our CouchDB documents, but we haven't had to actually use it in our application. In order for us to take any actions on an already existing document, we'll need to pass _rev, along with _id, to ensure that we are acting on the most recent document.

Let's prepare for this by adding a $_rev variable to our base class.

  1. Open classes/base.php in your working directory, and add the $_rev variable.
    abstract class Base
    {
    protected $_id;
    protected $_rev;
    
    protected $type;
    
  2. Unfortunately, now anytime we call the to_json function, _rev will always be included, regardless of it being used or not. If we were to send CouchDB a null _rev, it would throw an ...

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