src/CouchDB/Database.php
public function update($id, array &$doc)
    {
        $json = JSONEncoder::encode($doc);

        $response = $this->client->request('PUT', "/{$this->name}/{$id}", [
            'body'    => $json,
            'headers' => ['Content-Type' => 'application/json'],
        ]);

        if (201 !== $response->getStatusCode()) {
            throw new Exception('Unable to save document');
        }

        $value = JSONEncoder::decode((string) $response->getBody());

        $doc['_id'] = $value['id'];
        $doc['_rev'] = $value['rev'];
    }
public function update($id, array &$doc)
    {
        $json = JSONEncoder::encode($doc);

        $response = $this->client->request('PUT', "/{$this->name}/{$id}", [
            'body'    => $json,
            'headers' => ['Content-Type' => 'application/json'],
        ]);

        if (201 !== $response->getStatusCode()) {
            throw new Exception('Unable to save document');
        }

        $value = JSONEncoder::decode((string) $response->getBody());

        $doc['_id'] = $value['id'];
        $doc['_rev'] = $value['rev'];
    }
public function update ( $ id , array & $ doc ) { $ json = JSONEncoder :: encode ( $ doc ) ; $ response = $ this -> client -> request ( 'PUT' , "/{$this->name}/{$id}" , [ 'body' => $ json , 'headers' => [ 'Content-Type' => 'application/json' ] , ] ) ; if ( 201 !== $ response -> getStatusCode ( ) ) { throw new Exception ( 'Unable to save document' ) ; } $ value = JSONEncoder :: decode ( ( string ) $ response -> getBody ( ) ) ; $ doc [ '_id' ] = $ value [ 'id' ] ; $ doc [ '_rev' ] = $ value [ 'rev' ] ; }
Updates a document.

@param string $id  The id from the document
@param array  $doc A reference from the document

@throws Exception
Updates a document .