\Couchbase

Interfaces

Authenticator Interface of authentication containers.
SearchFacet Common interface for all search facets
SearchQueryPart Common interface for all classes, which could be used as a body of SearchQuery
ViewQueryEncodable Common interface for all View queries

Classes

AnalyticsQuery Represents a Analytics query (currently experimental support).
BooleanFieldSearchQuery A FTS query that queries fields explicitly indexed as boolean.
BooleanSearchQuery A compound FTS query that allows various combinations of sub-queries.
Bucket Represents connection to the Couchbase Server
BucketManager Provides management capabilities for the Couchbase Bucket
CertAuthenticator Authenticator for Client Certificate authentication feature of Couchbase Server 5+.
ClassicAuthenticator Authenticator based on login/password credentials.
Cluster Represents a Couchbase Server Cluster.
ClusterManager Provides management capabilities for a Couchbase Server Cluster
ConjunctionSearchQuery A compound FTS query that performs a logical AND between all its sub-queries (conjunction).
DateRangeSearchFacet A facet that categorizes hits inside date ranges (or buckets) provided by the user.
DateRangeSearchQuery A FTS query that matches documents on a range of values. At least one bound is required, and the inclusiveness of each bound can be configured.
DisjunctionSearchQuery A compound FTS query that performs a logical OR between all its sub-queries (disjunction). It requires that a minimum of the queries match. The minimum is configurable (default 1).
DocIdSearchQuery A FTS query that matches on Couchbase document IDs. Useful to restrict the search space to a list of keys (by using this in a compound query).
Document Represents Couchbase Document, which stores metadata and the value.
DocumentFragment A fragment of a JSON Document returned by the sub-document API.
Exception Exception represeting all errors generated by the extension
GeoBoundingBoxSearchQuery A FTS query which allows to match geo bounding boxes.
GeoDistanceSearchQuery A FTS query that finds all matches from a given location (point) within the given distance.
LookupInBuilder A builder for subdocument lookups. In order to perform the final set of operations, use the execute() method.
MatchAllSearchQuery A FTS query that matches all indexed documents (usually for debugging purposes).
MatchNoneSearchQuery A FTS query that matches 0 document (usually for debugging purposes).
MatchPhraseSearchQuery A FTS query that matches several given terms (a "phrase"), applying further processing like analyzers to them.
MatchSearchQuery A FTS query that matches a given term, applying further processing to it like analyzers, stemming and even #fuzziness(int).
MutateInBuilder A builder for subdocument mutations. In order to perform the final set of operations, use the execute() method.
MutationState Container for mutation tokens.
MutationToken An object which contains meta information of the document needed to enforce query consistency.
N1qlIndex Represents N1QL index definition
N1qlQuery Represents a N1QL query
NumericRangeSearchFacet A facet that categorizes hits into numerical ranges (or buckets) provided by the user.
NumericRangeSearchQuery A FTS query that matches documents on a range of values. At least one bound is required, and the inclusiveness of each bound can be configured.
PasswordAuthenticator Authenticator based on RBAC feature of Couchbase Server 5+.
PhraseSearchQuery A FTS query that matches several terms (a "phrase") as is. The order of the terms mater and no further processing is applied to them, so they must appear in the index exactly as provided. Usually for debugging purposes, prefer MatchPhraseQuery.
PrefixSearchQuery A FTS query that allows for simple matching on a given prefix.
QueryStringSearchQuery A FTS query that performs a search according to the "string query" syntax.
RegexpSearchQuery A FTS query that allows for simple matching of regular expressions.
SearchQuery Represents full text search query
SearchSort Base class for all FTS sort options in querying.
SearchSortField Sort by a field in the hits.
SearchSortGeoDistance Sort by a location and unit in the hits.
SearchSortId Sort by the document identifier.
SearchSortScore Sort by the hit score.
SpatialViewQuery Represents spatial Couchbase Map/Reduce View query
TermRangeSearchQuery A FTS query that matches documents on a range of values. At least one bound is required, and the inclusiveness of each bound can be configured.
TermSearchFacet A facet that gives the number of occurrences of the most recurring terms in all hits.
TermSearchQuery A facet that gives the number of occurrences of the most recurring terms in all hits.
UserSettings Represents settings for new/updated user.
ViewQuery Represents regular Couchbase Map/Reduce View query
WildcardSearchQuery A FTS query that allows for simple matching using wildcard characters (* and ?).

Constants

ENCODER_COMPRESSION_FASTLZ

ENCODER_COMPRESSION_FASTLZ

Use FastLZ compressor for the documents

ENCODER_COMPRESSION_NONE

ENCODER_COMPRESSION_NONE

Do not use compression for the documents

ENCODER_COMPRESSION_ZLIB

ENCODER_COMPRESSION_ZLIB

Use zlib compressor for the documents

ENCODER_FORMAT_IGBINARY

ENCODER_FORMAT_IGBINARY

Encodes documents using pecl/igbinary encoder (see INI section for details)

ENCODER_FORMAT_JSON

ENCODER_FORMAT_JSON

Encodes documents as JSON objects (see INI section for details)

ENCODER_FORMAT_PHP

ENCODER_FORMAT_PHP

Encodes documents using PHP serialize() (see INI section for details)

HAVE_IGBINARY

HAVE_IGBINARY

If igbinary extension was not found during build phase this constant will store 0

HAVE_ZLIB

HAVE_ZLIB

If libz headers was not found during build phase this constant will store 0

Functions

basicDecoderV1()

basicDecoderV1(string  $bytes, integer  $flags, integer  $datatype, array  $options) : mixed

Decodes value according to Common Flags (RFC-20)

Parameters

string $bytes

Binary string received from the Couchbase, which contains encoded document

integer $flags

Flags which describes document encoding

integer $datatype

Extra field for datatype (not used at the moment)

array $options

Returns

mixed —

Decoded document object

basicEncoderV1()

basicEncoderV1(mixed  $value, array  $options) : array

Encodes value according to Common Flags (RFC-20)

Parameters

mixed $value

document to be stored in the Couchbase

array $options

Encoder options (see detailed description in INI section)

  • "sertype" (default: \Couchbase::ENCODER_FORMAT_JSON) encoding format to use
  • "cmprtype" (default: \Couchbase::ENCODER_COMPRESSION_NONE) compression type
  • "cmprthresh" (default: 0) compression threshold
  • "cmprfactor" (default: 0) compression factor

Returns

array —

Array with three values: [bytes, flags, datatype]

defaultDecoder()

defaultDecoder(string  $bytes, integer  $flags, integer  $datatype) : mixed

Decodes value using \Couchbase\basicDecoderV1.

It passes couchbase.decoder.* INI properties as $options.

Parameters

string $bytes

Binary string received from the Couchbase, which contains encoded document

integer $flags

Flags which describes document encoding

integer $datatype

Extra field for datatype (not used at the moment)

Returns

mixed —

Decoded document object

defaultEncoder()

defaultEncoder(mixed  $value) : array

Encodes value using \Couchbase\basicDecoderV1.

It passes couchbase.encoder.* INI properties as $options.

Parameters

mixed $value

document to be stored in the Couchbase

Returns

array —

Array with three values: [bytes, flags, datatype]

fastlzCompress()

fastlzCompress(string  $data) : string

Compress input using FastLZ algorithm.

Parameters

string $data

original data

Returns

string —

compressed binary string

fastlzDecompress()

fastlzDecompress(string  $data) : string

Decompress input using FastLZ algorithm.

Parameters

string $data

compressed binary string

Returns

string —

original data

passthruDecoder()

passthruDecoder(string  $bytes, integer  $flags, integer  $datatype) : string

Returns value as it received from the server without any transformations.

It is useful for debug purpose to inspect bare value.

Parameters

string $bytes
integer $flags
integer $datatype

Returns

string —

Document as it received from the Couchbase.

Examples

<?php
$cluster = new \Couchbase\Cluster("couchbase://localhost");
$bucket = $cluster->openBucket("default");
$bucket->setTranscoder("\\Couchbase\\defaultEncoder", "\\Couchbase\\passthruDecoder");
$bucket->upsert("foo", ["bar" => "baz"]);
$value = $bucket->get("foo")->value;
var_dump($value);
// => string(13) "{"bar":"baz"}"

passthruEncoder()

passthruEncoder(string  $value) : array

Returns the value, which has been passed and zero as flags and datatype.

It is useful for debug purposes, or when the value known to be a string, otherwise behavior is not defined (most likely it will generate error).

Parameters

string $value

document to be stored in the Couchbase

Returns

array —

Array with three values: [bytes, 0, 0]

zlibCompress()

zlibCompress(string  $data) : string

Compress input using zlib. Raises Exception when extension compiled without zlib support.

Parameters

string $data

original data

Returns

string —

compressed binary string

zlibDecompress()

zlibDecompress(string  $data) : string

Compress input using zlib. Raises Exception when extension compiled without zlib support.

Parameters

string $data

compressed binary string

Returns

string —

original data