Character escaping in where clause
- Member | 1
i' trying to use the new jsonb operator of Postgresl
one of them is “?” like in
<?php delete from users where myfield::jsonb ? 'akey' ?>
i'm trying to use the where() method but of course, it auto escape the ? character and wait for a parameters.
<?php ->where('myfield::jsonb ? 'akey')) ?>
or tried to fool it with
<?php ->where('myfield::jsonb ?', "? 'akey')) ?>
<?php ->where('myfield::jsonb ?', $con::literal("? 'akey'")) ?>
but it always throw me some errors like “There are more placeholders than passed parameters.” Argument count does not match placeholder count.", etc
the problem is obviously the ? characters which is used by nett database processing AND postgres json !
Is there an easy way to add a where clause with preprocessing disabled?
Thank you for any help
Last edited by eincandea (2019-09-30 22:08)
- Jan Tvrdík
- Nette guru | 2595
Such query in AFAIK impossible with PDO in PHP < 7.4. See https://wiki.php.net/…placeholders for details.