We were initially using: /$couchResult = json_decode(json_encode($couchBucket->query($couchQuery)), true);
but I was advised that as this is encoding and then decoding it uses more resources. @srm gave me a tip on how to optimise this by using: $couchResult = $couchBucket->query(\CouchbaseN1qlQuery::fromString($couchQuery), true);
However, I am receiving this PHP error.
An exception occurred: LCB_EINVAL: Invalid input/arguments in [CouchbaseNative]/CouchbaseBucket.class.php on line 316
_CouchbaseBucket->n1ql_request() in [CouchbaseNative]/CouchbaseBucket.class.php at line 316
CouchbaseBucket->_n1ql() in [CouchbaseNative]/CouchbaseBucket.class.php at line 378
CouchbaseBucket->query() in /var/www/exfusion.net/html/unlink.php at line 48
couchbase support enabled
extension version 2.2.0
libcouchbase runtime version 2.6.2 (git: 788e1eeda075eddd8204ecc3fc5028add74e8074)
libcouchbase headers version 2.6.2 (git: 788e1eeda075eddd8204ecc3fc5028add74e8074)
Ooh, thanks to both of you! I’ve got it working again. I didn’t realise that CouchBucket query accepted a second parameter to return it as an array. (is it just me who finds that the official documentation is difficult to find???)
Sorry but what do I do here to fetch as an array? try { $couchResult = $couchBucket->get("playerdata:" . $fields["mcuuid"]); } catch (Exception $ex) { return false; }
Getting non-existent key. Should fail
Error: LCB_KEY_ENOENT: The key does not exist on the server (0xd)
Upserting...
Getting
array(1) {
["foo"]=>
string(3) "bar"
}
Foo is: bar
what is different? when you store a string, you will get a string back, when you store an object, it will be transparently encoded as JSON object, and you would get the object back.
result of the query wraps the objects into a map, because you could query multiple buckets in the single query, but inside, it still the same representation of the object.