コード例 #1
0
 /**
  * set the security object of a database
  *
  * @link http://wiki.apache.org/couchdb/Security_Features_Overview
  * @param stdClass $security the security object to apply to the database
  * @return stdClass CouchDB server response ( { "ok": true } )
  * @throws InvalidArgumentException|couchException
  */
 public function setSecurity($security)
 {
     if (!is_object($security)) {
         throw new InvalidArgumentException("Security should be an object");
     }
     $dbname = $this->client->getDatabaseName();
     $raw = $this->client->query("PUT", "/" . $dbname . "/_security", array(), json_encode($security));
     $resp = couch::parseRawResponse($raw);
     if ($resp['status_code'] == 200) {
         return $resp['body'];
     }
     throw new couchException($raw);
 }
コード例 #2
0
 /**
  * @param $id
  * @return Document
  * @throws CouchDbException
  */
 public function getDocumentById($id)
 {
     try {
         $response = $this->client->get($this->getDocumentUrl($id), 200, $this->server->getOptions());
         $document = new Document();
         $document->populateFromArray($response);
         return $document;
     } catch (CouchDbException $exception) {
         // If exception was a 404 the document was not found. So we can create one using $id
         if ($exception->getCode() == 404) {
             $document = new Document($id);
             return $document;
         } else {
             throw $exception;
         }
     }
 }
コード例 #3
0
 /**
  * @return array
  */
 public function listDbs()
 {
     return $this->client->get($this->getServerUrl() . '/_all_dbs', 200, $this->getOptions());
 }