couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Couchdb Wiki] Update of "GettingStartedWithPhp" by tapwater
Date Mon, 21 Jul 2008 17:49:27 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Couchdb Wiki" for change notification.

The following page has been changed by tapwater:
http://wiki.apache.org/couchdb/GettingStartedWithPhp

The comment on the change is:
Updated content type and temporary view format.

------------------------------------------------------------------------------
          $req = "{$this->method} {$this->url} HTTP/1.0\r\nHost: {$this->host}\r\n";
          if($this->data) {
              $req .= 'Content-Length: '.strlen($this->data)."\r\n";
-             $req .= 'Content-Type: text/javascript'."\r\n\r\n";
+             $req .= 'Content-Type: application/json'."\r\n\r\n";
              $req .= $this->data."\r\n";
          } else {
              $req .= "\r\n";
@@ -289, +289 @@

  
  // if we want to find only pastebin items that are currently published, we need to do a
little more.
  // below, we create a view using a javascript function passed in the post data.
- $view = <<<VIEW
+ $map = <<<MAP
  function(doc) {
      if(doc.status == 'published') {
-         map(doc.title, {docTitle: doc.title, docBody: doc.body});
+         emit(doc.title, {docTitle: doc.title, docBody: doc.body});
      }
  }
- VIEW;
+ MAP;
+ $view = '{"map":"'.$map.'"}';
  
  // we set the method to POST and send the request to couch db's /_temp_view. the text of
the view is passed as post data.
  // this javascript function will return documents whose 'status' field contains 'published'.

Mime
View raw message