Updating documents

You can update a document by using the upsert() or replace() methods.

The replace() method replaces a document that already exists with new contents. The upsert() method creates the document if it does not already exist.

The following example shows how to update a document by using the replace() method:

$myBucket = $myCluster->openBucket();
$res = $myBucket->replace('document_name', array('some'=>'value'));
var_dump($res);

Sample output from the example:

object(CouchbaseMetaDoc)#4 (4) {
  ["cas"]=>
  resource(5) of type (CAS)
}