how to correct pass parameter/values to whereRaw

32 Views Asked by At

i need to parametrize a db table and field in a whereRaw with a JsonExtract:

        $query = $query->whereRaw("JSON_EXTRACT(?, ? ) = ? ", [ "a.tags",'$.' . $orgKey, $orgValue]);

this won't work, this yes:

        $query = $query->whereRaw("JSON_EXTRACT(a.tags, ? ) = ? ", ['$.' . $orgKey, $orgValue]);

how can I fix this? the error, even if the query is correctly binded, this error is returned:

SQLSTATE[22032]: <>: 3141 Invalid JSON text in argument 1 to function cast_as_json: "Invalid value." at position 0.

0

There are 0 best solutions below