N1QL query throwing exception: LCB_EINVAL: Invalid input/arguments

Current setup:

Docker image with: Version: 4.5.0-2601 Enterprise Edition (build-2601)


PHP Version 5.6.23

couchbase support	enabled
extension version	2.2.0
libcouchbase runtime version	2.6.1 (git: eb09707433013b742c0aa221e564ad73ba8a3708)
libcouchbase headers version	2.6.1 (git: eb09707433013b742c0aa221e564ad73ba8a3708)

When running the example hello-couchbase.php provided in http://developer.couchbase.com/documentation/server/current/sdk/php/start-using-sdk.html

It runs ok until the N1QL query, then it throws an exception:

CouchbaseException in CouchbaseBucket.class.php line 316:
LCB_EINVAL: Invalid input/arguments
in CouchbaseBucket.class.php line 316
at _CouchbaseBucket->n1ql_request('{"statement":"SELECT * FROM `default` WHERE $p IN interests"}', true) in CouchbaseBucket.class.php line 316
at CouchbaseBucket->_n1ql(object(CouchbaseN1qlQuery), array('p' => 'African Swallows')) in CouchbaseBucket.class.php line 378


// Query with parameters
$query = CouchbaseN1qlQuery::fromString("SELECT * FROM `default` WHERE \$p IN interests");
echo "Parameterized query:\n";
$rows = $bucket->query($query, array("p" => "African Swallows"));
echo "Results:\n";

The same query on the web interface, runs perfectly:

    "default": {
      "email": "kingarthur@couchbase.com",
      "interests": [
        "African Swallows",
        "PHP 7"

Am I missing anything here?

Sorry, the docs hasn’t been updated after the code change. You should do it like this

$query = CouchbaseN1qlQuery::fromString("SELECT * FROM `default` WHERE \$p IN interests");
$query->namedParams(array("p" => "African Swallows"));
echo "Parameterized query:\n";
$rows = $bucket->query($query);
echo "Results:\n";

like described here http://developer.couchbase.com/documentation/server/4.5/sdk/php/n1ql-queries-with-sdk.html