String or Object. Type returned data by the client

Hello.

@avsej

Again, I can not understand the results of the responses.

Situation number 1:

Ubuntu server 14.04
PHP 7.0.7-2+donate.sury.org~trusty+1 (cli) ( NTS )
Apache2
Couchbase cli 2.2.0beta3

i’m do:

$document = ["aaa" => "bbb", "ccc" => "ddd"];
$docName = "0001Test";

$bucketArticle = $welcome->autoConnectToBucket(["bucket" => "article"]);
try {
    $bucketArticle->insert($docName, $document);
} catch (Exception $e) {
    echo "Not . " . $e->getMessage();
}

Then:

$bucketArticle = $welcome->autoConnectToBucket(["bucket" => "article"]);
try {
    $res = $bucketArticle->get("0001Test");
    echo "\n\r<br>---> <b>res: </b><br>";
    var_dump($res);
} catch (Exception $e) {
    echo "Not found. " . $e->getMessage();
}

Result:

---> res: 
object(CouchbaseMetaDoc)#7 (4) {
  ["error"]=>
  NULL
  ["value"]=>
  string(25) "{"aaa":"bbb","ccc":"ddd"}"
  ["flags"]=>
  int(0)
  ["cas"]=>
  string(10) "23e6g3zkt0"
}

Situation number 2:

Ubuntu server 14.04
PHP 5.5.9-1ubuntu4.17 (cli) (built: May 19 2016 19:05:57)
Apache2
Couchbase cli 2.0.7

i’m do:

$document = ["aaa" => "bbb", "ccc" => "ddd"];
$docName = "0002Test";

$bucketArticle = $welcome->autoConnectToBucket(["bucket" => "article"]);
try {
    $bucketArticle->insert($docName, $document);
} catch (Exception $e) {
    echo "Not . " . $e->getMessage();
}

Then:

$bucketArticle = $welcome->autoConnectToBucket(["bucket" => "article"]);
try {
    $res = $bucketArticle->get("0002Test");
    echo "\n\r<br>---> <b>res: </b><br>";
    var_dump($res);
} catch (Exception $e) {
    echo "Not found. " . $e->getMessage();version
}

Result:

---> res: 
object(CouchbaseMetaDoc)#10 (4) {
  ["error"]=>
  NULL
  ["value"]=>
  object(stdClass)#7 (2) {
    ["aaa"]=>
    string(3) "bbb"
    ["ccc"]=>
    string(3) "ddd"
  }
  ["flags"]=>
  int(33554438)
  ["cas"]=>
  string(10) "27wg6eyolw"
}

In both cases, I get different results:

  • Situation number 1: value - string

  • Situation number 2: value - object(stdClass)

Why when I changed the version of the client has changed the type of data?

Thank you.

For some reason first document do not have flags setup properly. Did you change transcoders or their settings?

No, I have not changed transcoders or their settings.

Here’s another old document. This document I created using Couchbase cli 2.0.7

---> res: 
object(CouchbaseMetaDoc)#16 (4) {
  ["error"]=>
  NULL
  ["value"]=>
  object(stdClass)#7 (14) {
    ["docId"]=>
    string(24) "2683d30f25d377124fe074ec"
    ["createdAt"]=>
    int(1451739622)
    ["updatedAt"]=>
    int(1451739622)
    ["article"]=>
    string(46) "at-drink-philly-were-excited-to-help-guide-you"
    ["time"]=>
    string(8) "07:09:16"
    ["date"]=>
    string(10) "2011/07/21"
    ["title"]=>
    string(47) "At Drink Philly we're excited to help guide you"

...   

    }
  }
  ["flags"]=>
  int(33554438)
  ["cas"]=>
  string(13) "2ndnkwt7g3pj4"
}

[“value”]=> object(stdClass)

The Developer documentation states that the answer must be in the form of ARRAY:

Couchbase SDKs

The following example shows a regular read:

$myBucket = $myCluster->openBucket();
$res = $myBucket->get(‘document_name’);
var_dump($res); 

Sample output from the example:

 object(CouchbaseMetaDoc)#4 (4) {
  ["value"]=>
  array(1) {
    ["name"]=>
    string(5) "Frank"
  }
  ["flags"]=>
  int(4)
  ["cas"]=>
  resource(5) of type (CAS)
}

In my case, a completely different result.

Okay, it turned out to be a bug in beta version. It has been fixed in http://review.couchbase.org/64926

Thank you @avsej.

I’ll try to use version 2.1.0.

Yeah right.

If I use the version couchbase-2.2.0beta2 is the correct result is obtained:

---> res: 
object(CouchbaseMetaDoc)#10 (4) {
  ["error"]=>
  NULL
  ["value"]=>
  object(stdClass)#7 (2) {
    ["aaa"]=>
    string(3) "bbb"
    ["ccc"]=>
    string(3) "ddd"
  }
  ["flags"]=>
  int(33554438)
  ["cas"]=>
  resource(2) of type (CouchbaseCAS)
}

Couchbase cli version 2.1.0 could not be established. I got pecl error:

make: *** [bucket.lo] Error 1
ERROR: `make' failed