Working with N1QL queries
You can perform Couchbase Query Language (N1QL) queries via the PHP SDK.
To send N1QL queries, you must specify a list of application query hosts through the enableN1ql()method (a temporary necessity). After you have done this, you can perform a N1QL query by using the query() method, which accepts a query created through the CouchbaseN1qlQuery class. You receive an array of objects representing the results.
The following example shows how to send a N1QL query:
$myBucket = $myCluster->openBucket();
$query = CouchbaseN1qlQuery::fromString('SELECT * FROM default');
$res = $myBucket->query($query);
var_dump($res);
Sample output from the example:
array(2) {
[0]=>
array(1) {
["field_name"]=>
string("value1")
}
[1]=>
array(1) {
["field_name"]=>
string("value2")
}
}