\CouchbaseAnalyticsQuery

Represents a Analytics query (currently experimental support).

Summary

Methods
Properties
Constants
fromString()
hostname()
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

fromString()

fromString(string  $statement) : \Couchbase\AnalyticsQuery

Creates new AnalyticsQuery instance directly from the string.

Parameters

string $statement

statement string

Returns

\Couchbase\AnalyticsQuery

Examples

<?php
$cluster = new \Couchbase\Cluster('couchbase://localhost?detailed_errcodes=1');
$bucket = $cluster->openBucket('beer-sample');

$query = \Couchbase\AnalyticsQuery::fromString('SELECT "Hello, beer!" AS greeting;');
$query->hostname('localhost:8095/query/service'); // while the feature in experimental mode
$res = $bucket->query($query);
var_dump($res->rows[0]);
//=> object(stdClass)#4 (1) {
//     ["greeting"]=>
//     string(12) "Hello, beer!"
//   }

hostname()

hostname(string  $hostname) : \Couchbase\AnalyticsQuery

Sets query service location.

Note that this method accessible only while Analytics support is experimental. It will be removed after GA release of this feature, and service location will be supplied in cluster config.

Parameters

string $hostname

location of the analytics service. Usually something like "localhost:8095/query/service"

Returns

\Couchbase\AnalyticsQuery