Positional params placeholder should NOT be $

The choice of $ as the positional placeholder character within a PHP N1QL is completely baffling. Of ALL characters available, by far the WORST choice for the placeholder is $ because $ is reserved by PHP to delimit a variable. As such, $ is literally the ONLY character that absolutely should NOT have been chosen. ANY other special character would have been a better choice.

Constructing a N1QL statement that contains both a positional placeholder AND a PHP variable (which constitutes the bulk of the queries I write) is now heavily bogged down by escaping and chunking work that makes even simple dynamic queries difficult to read and highly error prone.

$name = $_GET['name'];
$n1ql = "SELECT * FROM bucket WHERE type=$1 AND name=$name "; //interpolation error $1 treated like a var
$n1ql = 'SELECT * FROM bucket WHERE type=$1 AND name=' . $name; //inconvenient, unnecessary, easy to forget
$n1sql = "SELECT * FROM bucket WHERE type=\$1 AND name=$name"; //also inconvenient and easy to forget!

What a mess. All because the PHP SDK falsely assumed it could use the ONE character it absolutely should NOT have used to delimit a positional placeholder within a N1QL string.

Why not use ^ as the placeholder parameter instead?

$n1ql = "SELECT * FROM bucket WHERE type=^1 AND name=$name"; //no problem, easy to type, easy to escape, easy to read!

Please change this!

Welcome to the forums and thank you for posting.
@Robert_Mirabelle thanks for the feedback and understand your concerns. Will review your feedback and get back to you !

the PHP SDK does not have lexer and/or parser for N1QL language built-in, so we cannot change the interpolation rules. Unfortunately as you have noticed PHP itself interpolates dollar signs in double-quoted strings.

So the only solution is to either escape all dollars that have to be relayed to N1QL, or use single-quoted strings.

This is just the same you would do if you want to include backslash or double quotes and single quotes in the same string.