couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Pitman <>
Date Wed, 04 Aug 2010 06:33:21 GMT
Not exactly sure what you're after here, but I had a similar thought that
the existing php classes for dealing with couchdb are a bit heavyweight, so
a little while ago I wrote myself a nice simple one.  I haven't put it up on
github yet because it doesn't support couchdb with any features introduced
since about 0.8 (not "shows", "lists", no oauth authentication, etc.) but it
has helped me in the meantime with a couple of projects.  I haven't touched
this code since about a year ago, which is why it is out of date as regards
couchdb features support.

A sample of the usage (from my personal documentation for it) follows:

$couch = new SimpleCouch( array('first' => array('host'=>'',
'port'=>80, 'username'=>COUCH_USER, 'password'=>COUCH_PASSWORD) ) );
$first = $couch->first;  //gives a SimpleCouchServer object, with basic
authentication at
$db = $first->db; //a SimpleCouchDatabase object
$db->doc;  // returns the SimpleCouchDocument at,
returns blank document if not existing
$doc->_( array("field1"=>"some data", "field2"=>"more data"),
"field3"=>true, "field4"=>325 );
// update with the given data
$doc->field1; //gives "some data"
$doc->field1 = "some new data"; // update the value of field1

unset( $doc->field1 );
// delete field1 locally

$doc->_( null, false ); //updates local copy from server data
unset( $doc->field1 ); // delete local field1
$doc->_( null, true ); // duplicates local data onto server version, exact
//effectively delete field1 on server

//convert $doc to a string to it as  a JSON string, e.g.
echo $doc;
// gets '{"_id":"doc", "_rev":1, "field2": "more data", "field3":true,
"field4":325}' or similar


If you think that something like this would be useful to you, I will
endeavour to look through this code again ASAP and put it up on github.


David Pitman

On Tue, Aug 3, 2010 at 5:00 AM, Paul J Barrett <> wrote:

> I see many examples of using some library api to use php with couchdb, but
> I don't see anything that demonstrates using json and making the put, post,
> get, delete directly using the REST interface.
> Is it that difficult to use php directly with couchdb that you need the
> added frameworks? I only work with php infrequently so I am no master php
> developer but it seems a little overly complicated considering that most
> Couchdb tutorials demonstrate the basics using curl. The websites I develop
> usually have some simple forms (guest book, or something similar) and simple
> retrieval mechanisms so I am looking for the simplest way to start using
> couchdb.
> I am interested in learning about couchdb and how it solves problems
> differently or better than a sql server.
> Thanks in advance for your input on the above questions and statements.
> Paul

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message