class N1qlQuery (View source)

Represents a N1QL query

Constants

NOT_BOUNDED

This is the default (for single-statement requests).

No timestamp vector is used in the index scan. This is also the fastest mode, because we avoid the cost of obtaining the vector, and we also avoid any wait for the index to catch up to the vector.

REQUEST_PLUS

This implements strong consistency per request.

Before processing the request, a current vector is obtained. The vector is used as a lower bound for the statements in the request. If there are DML statements in the request, RYOW is also applied within the request.

STATEMENT_PLUS

This implements strong consistency per statement.

Before processing each statement, a current vector is obtained and used as a lower bound for that statement.

PROFILE_NONE

Disables profiling. This is the default

PROFILE_PHASES

Enables phase profiling.

PROFILE_TIMINGS

Enables general timing profiling.

Methods

static N1qlQuery
fromString(string $statement)

Creates new N1qlQuery instance directly from the N1QL string.

adhoc(bool $adhoc)

Allows to specify if this query is adhoc or not.

crossBucket(bool $crossBucket)

Allows to pull credentials from the Authenticator

positionalParams(array $params)

Specify array of positional parameters

namedParams(array $params)

Specify associative array of named parameters

consistency(int $consistency)

Specifies the consistency level for this query

profile(string $profileType)

Controls the profiling mode used during query execution

consistentWith(MutationState $state)

Sets mutation state the query should be consistent with

readonly(bool $readonly)

If set to true, it will signal the query engine on the server that only non-data modifying requests are allowed. Note that this rule is enforced on the server and not the SDK side.

scanCap(int $scanCap)

Advanced: Maximum buffered channel size between the indexer client and the query service for index scans.

pipelineBatch(int $pipelineBatch)

Advanced: Controls the number of items execution operators can batch for Fetch from the KV.

pipelineCap(int $pipelineCap)

Advanced: Maximum number of items each execution operator can buffer between various operators.

maxParallelism(int $maxParallelism)

Allows to override the default maximum parallelism for the query execution on the server side.

Details

static N1qlQuery fromString(string $statement)

Creates new N1qlQuery instance directly from the N1QL string.

Parameters

string $statement

N1QL string

Return Value

N1qlQuery

N1qlQuery adhoc(bool $adhoc)

Allows to specify if this query is adhoc or not.

If it is not adhoc (so performed often), the client will try to perform optimizations transparently based on the server capabilities, like preparing the statement and then executing a query plan instead of the raw query.

Parameters

bool $adhoc

if query is adhoc, default is true (plain execution)

Return Value

N1qlQuery

N1qlQuery crossBucket(bool $crossBucket)

Allows to pull credentials from the Authenticator

Parameters

bool $crossBucket

if query includes joins for multiple buckets (default is false)

Return Value

N1qlQuery

See also

Authenticator
ClassicAuthenticator

N1qlQuery positionalParams(array $params)

Specify array of positional parameters

Previously specified positional parameters will be replaced. Note: carefully choose type of quotes for the query string, because PHP also uses $ (dollar sign) for variable interpolation. If you are using double quotes, make sure that N1QL parameters properly escaped.

Parameters

array $params

Return Value

N1qlQuery

N1qlQuery namedParams(array $params)

Specify associative array of named parameters

The supplied array of key/value pairs will be merged with already existing named parameters. Note: carefully choose type of quotes for the query string, because PHP also uses $ (dollar sign) for variable interpolation. If you are using double quotes, make sure that N1QL parameters properly escaped.

Parameters

array $params

Return Value

N1qlQuery

N1qlQuery consistency(int $consistency)

Specifies the consistency level for this query

Parameters

int $consistency

consistency level

Return Value

N1qlQuery

See also

N1qlQuery::NOT_BOUNDED
N1qlQuery::REQUEST_PLUS
N1qlQuery::STATEMENT_PLUS
N1qlQuery::consistentWith

N1qlQuery profile(string $profileType)

Controls the profiling mode used during query execution

Parameters

string $profileType

Return Value

N1qlQuery

See also

N1qlQuery::PROFILE_NONE
N1qlQuery::PROFILE_PHASES
N1qlQuery::PROFILE_TIMINGS

N1qlQuery consistentWith(MutationState $state)

Sets mutation state the query should be consistent with

Parameters

MutationState $state

the container of mutation tokens

Return Value

N1qlQuery

See also

MutationState

N1qlQuery readonly(bool $readonly)

If set to true, it will signal the query engine on the server that only non-data modifying requests are allowed. Note that this rule is enforced on the server and not the SDK side.

Controls whether a query can change a resulting record set.

If readonly is true, then the following statements are not allowed:

  • CREATE INDEX
  • DROP INDEX
  • INSERT
  • MERGE
  • UPDATE
  • UPSERT
  • DELETE

Parameters

bool $readonly

true if readonly should be forced, false is the default and will use the server side default.

Return Value

N1qlQuery

N1qlQuery scanCap(int $scanCap)

Advanced: Maximum buffered channel size between the indexer client and the query service for index scans.

This parameter controls when to use scan backfill. Use 0 or a negative number to disable.

Parameters

int $scanCap

the scan_cap param, use 0 or negative number to disable.

Return Value

N1qlQuery

N1qlQuery pipelineBatch(int $pipelineBatch)

Advanced: Controls the number of items execution operators can batch for Fetch from the KV.

Parameters

int $pipelineBatch

the pipeline_batch param.

Return Value

N1qlQuery

N1qlQuery pipelineCap(int $pipelineCap)

Advanced: Maximum number of items each execution operator can buffer between various operators.

Parameters

int $pipelineCap

the pipeline_cap param.

Return Value

N1qlQuery

N1qlQuery maxParallelism(int $maxParallelism)

Allows to override the default maximum parallelism for the query execution on the server side.

Parameters

int $maxParallelism

the maximum parallelism for this query, 0 or negative values disable it.

Return Value

N1qlQuery