Example #1
0
 public function parseResponse(CouchDBResponse $response)
 {
     $body_array = $response->getBody(true);
     foreach ($body_array as $key => $value) {
         if (in_array($key, array('_id', '_rev'))) {
             $this->{$key} = $value;
         } else {
             $this->data[$key] = $value;
         }
     }
 }
Example #2
0
 public function __construct(CouchDBResponse $response)
 {
     if ($response->isOk()) {
         $this->document_list = array();
         $data = $response->getBody(true);
         $this->count = $data['total_rows'];
         $this->offset = $data['offset'];
         if (isset($data['rows'])) {
             foreach ($data['rows'] as $documentData) {
                 $doc_id = $documentData['id'];
                 $doc_rev = $documentData['value']['rev'];
                 $data = isset($documentData['doc']) ? $documentData['doc'] : null;
                 unset($data['_id']);
                 unset($data['_rev']);
                 $_tmp = new Document();
                 $_tmp->parseData($doc_id, $doc_rev, $data);
                 $this->document_list[] = $_tmp;
             }
         }
     }
 }