/framework/experimental/couch/CouchConnection.php
http://zoop.googlecode.com/ · PHP · 38 lines · 33 code · 5 blank · 0 comment · 2 complexity · 2f0a48f2c4a0f0c23711a04e3a16c1d6 MD5 · raw file
- <?php
- class CouchConnection
- {
- private $http;
- private $dbName;
-
- function __construct($params)
- {
- if(!isset($params['host']))
- $params['host'] = 'localhost';
- if(!isset($params['port']))
- $params['port'] = 5984;
-
- $this->dbName = $params['database'];
- $this->http = new CouchHttp($params['host'], $params['port']);
- }
-
- public function getDbName()
- {
- return $this->dbName;
- }
-
- public function getHttp()
- {
- return $this->http;
- }
-
- public function getAllDocuments()
- {
- $documentInfo = $this->http->send("GET", "/{$this->dbName}/_all_docs");
- $documents = array();
- foreach($documentInfo->rows as $thisRow)
- {
- $documents[] = new CouchDocument($thisRow->id, $thisRow->value->rev);
- }
- return $documents;
- }
- }