I was trying to use N1QL in PHP…this first one is working:
$query = CouchbaseN1qlQuery::fromString("select count(*) from bucket1 where type = 'user'");
$res = $myBucket->query($query);
Output:
array(1) {
[0]=>
object(stdClass)#3 (1) {
["$1"]=>
int(58)
}
}
- When I changed to named parameter(s), it failed:
$query = CouchbaseN1qlQuery::fromString("select count(*) from bucket1 where type = $type");
$res = $myBucket->query($query, ['type' => 'user']);
I got ‘PHP Notice: Undefined variable: type…’ error
Can anyone help to instruct me the correct syntax to use named parameters for N1QL in PHP? The document of PHP SDK does not have N11QL’s WHERE clause example using named parameters…
my couchbase server is 4.1
appreciated for your help.