using php on couch: php-on-couch
I'm trying to pass in a startkey and endkey, this works:
$client->startkey( array( $val1, $val2) ) );
$client->endkey( array( $val1 , $val2) ) );
however this does not work:
$client->startkey( array( $val1) ) );
$client->endkey( array( $val1 , '{}') ) );
I think PHP is having trouble with the empty object. Any ideas?
Is it possible that the string '{}'
is not sent as an object, but instead as a string? You want to send (formatted for clarity)
startkey=%5B%22val1%22%5D // decodes to: ["val1"]
endkey=%5B%22val1%22%2C%7B%7D%5D // decodes to: ["val1",{}]
But maybe PHP on Couch is requesting
startkey=%5B%22val1%22%5D // decodes to: ["val1"]
endkey=%5B%22val1%22%2C%22%7B%7D%22%5D // decodes to: ["val1","{}"]
If that is the case (and I am guessing a bit), what about using an array (object) as the second element?
$client->startkey( array( $val1) ) );
$client->endkey( array( $val1 , array() ) ) );
Does that work?
code
$endkey = array("test",new stdClass) - Matt 2012-04-12 14:16
I am supplementing the @JasonSmith answer so that hopefully it will help someone else. This is the gist of what you need to clarify the above answer. The startkey and endkey will work if you pass them as array objects, even if you only need one parameter each.
$this->couchdb
->startkey(array($gallery_id))
->endkey(array($gallery_id))
->getView('galleries','by_galleryid');