2 months ago

Question mark in raw sql query cause problem

Posted 2 months ago by klik

Hi. I have a problem in my raw query select. Example query:

DB::select( DB::raw( 
"SELECT * FROM event e WHERE e.repeat_every->'daysInWeekRepeat' ? :dayNow" 
 ['dayNow' => 'mon' ]

(Original query is much more complicate this is only example.)

Column "repeat_every" is a jsonb column, and I have to use question mark to search param value in array. This question mark cause a problem "invalid paremeter number". In output insted of question mark I get first param passed to query.

SO how to write this query to ignore question mark as a placeholder?

Thank you.

Please sign in or create an account to participate in this conversation.