PHP SDK does not work with positional parameter


I’m playing with N1QL prepared statement.

named parameter works fine with PHP SDK, but positional parameters do not work as expected.

The following code returns a few rows as expected.

$q = CouchbaseN1qlQuery::fromString("select * from mybucket where form = $form");
$rows = $bucket->query($q, ['form' => 'subject']);

The following code returns an empty array

$q = CouchbaseN1qlQuery::fromString("select * from mybucket where form = $0");
$rows = $bucket->query($q, ['subject']);

What am I missing?


sorry about bumping it, but there is no place to send a bug.

After some test, the problem seems related to libcouchbase and no the PHP SDK.
For the moment, you should not use positional parameter.
Anywhere i think its a best practice to use name parameter.

I’m working on a query builder for n1ql. It is essential to have positional parameter working for it. For the moment, I’m prefixing number with ‘a’ for a workaround.

Thank you for the information!

I would like to hear from someone in the cb team though.

Even in a querybuilder named parameter are better.

Only if you explicitly bind it. There is simply no reason to use it if not needed. It will simply complicate things. Anyway, I think that is not related to this thread.

Positional parameter is there as a feature for a reason. I really would like to get it working.

@brett19 Sorry for bothering you, but it looks like you are the maintainer of PHP SDK. Do you have any idea on this issue?