/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
  2. class CouchConnection
  3. {
  4. private $http;
  5. private $dbName;
  6. function __construct($params)
  7. {
  8. if(!isset($params['host']))
  9. $params['host'] = 'localhost';
  10. if(!isset($params['port']))
  11. $params['port'] = 5984;
  12. $this->dbName = $params['database'];
  13. $this->http = new CouchHttp($params['host'], $params['port']);
  14. }
  15. public function getDbName()
  16. {
  17. return $this->dbName;
  18. }
  19. public function getHttp()
  20. {
  21. return $this->http;
  22. }
  23. public function getAllDocuments()
  24. {
  25. $documentInfo = $this->http->send("GET", "/{$this->dbName}/_all_docs");
  26. $documents = array();
  27. foreach($documentInfo->rows as $thisRow)
  28. {
  29. $documents[] = new CouchDocument($thisRow->id, $thisRow->value->rev);
  30. }
  31. return $documents;
  32. }
  33. }