Answer the question
In order to leave comments, you need to log in
Why can't use placeholder inside JSON (RedBeanPHP)?
Hello! I have a task: to check if "$username" has upvoted a record with id "$id". For this I wrote the following (PostgreSQL DB):
$foo = R::getRow('SELECT "votes"::jsonb @> \'{"upvote":[":username"]}\'::jsonb AS "is_upvoted" FROM "pages" WHERE "id" = :id', [":id"=>$id,":username"=>$username];
\'{\"upvote"\:[\":username\"]}\'
\'{"upvote"\:[:username]}\'
$foo = R::getRow('SELECT "votes"::jsonb @> \'{"upvote":["'.$username.'"]}\'::jsonb AS "is_upvoted" FROM "pages" WHERE "id" = :id', [":id"=>$id];
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question