$cb ->view still not working in couchbase 2.0 beta and php client?
I had this problem with views with the developer-previews and on testing today with beta release , I realized the problems are there, using the example:
<?php
$cb = new Couchbase("127.0.0.1:8091", "beer-sample", "", "beer-sample");
$result = $cb->view("dev_beer", "beer_by_name");
foreach($result["rows"] as $row) {
echo $row->key;
}
I still could not retrieve any data. anyone succeeded ?
Problem solved ,
It wasn't a problem with the php client but with the example php code as below:
$cb = new Couchbase("127.0.0.1:8091", "default", "", "default");
$cb->set("a", 1);
$result = $cb->view("design_doc","my_view");
foreach($result["rows"] as $row) {
echo $row->key;
}
haha the last line of code is suppose to be
echo $row["key"];
since the results are arrays.
Correct, that's because we parse the JSON string into an array and not into stdObjects (this is a flag you can set on json_decode).
The default query value for stale on views is update-after, meaning your first view request would trigger an update to the index but not return data, while the second one would. Did you try running that code sample twice?
Also, does the view work fine in the web console?