\CouchbaseLookupInBuilder

A builder for subdocument lookups. In order to perform the final set of operations, use the execute() method.

Instances of this builder should be obtained through \Couchbase\Bucket->lookupIn()

Summary

Methods
Properties
Constants
get()
getCount()
exists()
execute()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

get()

get(string  $path, array  $options = array()) : \Couchbase\LookupInBuilder

Get a value inside the JSON document.

Parameters

string $path

the path inside the document where to get the value from.

array $options

the array with command modificators. Supported values are

  • "xattr" (default: false) if true, the path refers to a location within the document's extended attributes, not the document body.

Returns

\Couchbase\LookupInBuilder

getCount()

getCount(string  $path, array  $options = array()) : \Couchbase\LookupInBuilder

Get a count of values inside the JSON document.

This method is only available with Couchbase Server 5.0 and later.

Parameters

string $path

the path inside the document where to get the count from.

array $options

the array with command modificators. Supported values are

  • "xattr" (default: false) if true, the path refers to a location within the document's extended attributes, not the document body.

Returns

\Couchbase\LookupInBuilder

exists()

exists(string  $path, array  $options = array()) : \Couchbase\LookupInBuilder

Check if a value exists inside the document.

This doesn't transmit the value on the wire if it exists, saving the corresponding byte overhead.

Parameters

string $path

the path inside the document to check for existence

array $options

the array with command modificators. Supported values are

  • "xattr" (default: false) if true, the path refers to a location within the document's extended attributes, not the document body.

Returns

\Couchbase\LookupInBuilder

execute()

execute() : \Couchbase\DocumentFragment

Perform several lookup operations inside a single existing JSON document, using a specific timeout

Returns

\Couchbase\DocumentFragment

Examples

<?php
$cluster = new \Couchbase\Cluster("couchbase://localhost");
$bucket = $cluster->openBucket('default');

$bucket->upsert('foo', ['path1' => 'value1']);

$result = $bucket->lookupIn('foo')
        ->get('path1')
        ->exists('path2')
        ->execute();

var_dump(count($result->value));      //=> int(2)

var_dump($result->value[0]['code']);  //=> int(0)    COUCHBASE_SUCCESS
var_dump($result->value[0]['value']); //=> string(6) "value1"

var_dump($result->value[1]['code']);  //=> int(63)  COUCHBASE_SUBDOC_PATH_ENOENT
var_dump($result->value[1]['value']); //=> NULL