PageRenderTime 36ms CodeModel.GetById 30ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/framework/experimental/couch/CouchConnection.php

http://zoop.googlecode.com/
PHP | 38 lines | 33 code | 5 blank | 0 comment | 2 complexity | 2f0a48f2c4a0f0c23711a04e3a16c1d6 MD5 | raw file
 1<?php
 2class CouchConnection
 3{
 4	private $http;
 5	private $dbName;
 6	
 7	function __construct($params)
 8	{
 9		if(!isset($params['host']))
10			$params['host'] = 'localhost';
11		if(!isset($params['port']))
12			$params['port'] = 5984;
13		
14		$this->dbName = $params['database'];
15		$this->http = new CouchHttp($params['host'], $params['port']);
16	}
17	
18	public function getDbName()
19	{
20		return $this->dbName;
21	}
22	
23	public function getHttp()
24	{
25		return $this->http;
26	}
27	
28	public function getAllDocuments()
29	{
30		$documentInfo = $this->http->send("GET", "/{$this->dbName}/_all_docs");
31		$documents = array();
32		foreach($documentInfo->rows as $thisRow)
33		{
34			$documents[] = new CouchDocument($thisRow->id, $thisRow->value->rev);
35		}
36		return $documents;
37	}
38}