Brand new install from source, both of couchbase and the PHP connector. Connecting OK using hello world code, but the $result->value field is still a serialized JSON string, so the subsequent lines don’t work as written in the example. I know I’m missing something obvious, but dang if I can figure out what.
For kicks I tried $myBucket->setTranscoder('json_encode', 'json_decode');
but that generated a different error (depth must be greater than 0).
For completeness, here’s the actual returned object. I expected $result->value to be a stdObj, rather than a string:
CouchbaseMetaDoc Object
(
[error] =>
[value] => {"name":"Juleøl","abv":5.9,"ibu":0.0,"srm":0.0,"upc":0,"type":"beer","brewery_id":"aass_brewery","updated":"2010-07-22 20:00:20","description":"The Norwegian Juleøl can be traced back more that 1000 years. The \"Gulatinglov\", one of the first Norwegian laws written in the 9th century, has a chapter on brewing beer for the midwinter celebration in January. The festivities were held to celebrate the Norse Gods; Odin, Frøy and Njord as well as the \"return\" of the sun.\r\nFurthermore, the tradition was adopted by the Vikings that brought Christianity to the country between 1000 and 1100. They moved the tradition to December in connection with the birth of Jesus. \r\nIn those days a farmer that did not set aside the best crop to produce the beer could lose his house to the king and the church. The law has been changed, but we promise you that we still use the very best of malt, yeast, hops, and pure Norwegian water to produce our Christmas beer.\r\n\r\nAass Juleøl has won most of the Norwegian Juleøl taste test conducted over time. For those of you that know what \"lutefisk\" is, Aass Juleøl is the perfect choice of beverage to this traditional Norwegian dish.","style":"Dark American-Belgo-Style Ale","category":"North American Ale"}
[flags] => 0
[cas] => Resource id #3
)
Update to add:
insterted the following:
$myBucket->setTranscoder(
function($object) {
print "encoding :\n";
var_dump($object);
print "\n\n".json_encode($object);
return json_encode($object);
},
function($string) {
return json_decode($string);
});
And got the expected object on get(). However, replace() returned an object with a null value and the document in the database was emptied as well. The outputs in the transcode function give every appearance that it is returning a reasonable value for the serialized string.
System info: MacOS X 10.10.4; php 5.6; php sdk version 2.0.7; couchbase: 3.1.0