php - Laravel (5.1) query builder does not properly add bindings to a raw select statement -
i'm using laravel 5.1 , have following simple query:
$searchterm = 'random word'; $subquery = db::table('userprofile')->selectraw(" user_id, match(first_name, last_name) against('?*' in boolean mode) search_score ") ->addbinding($searchterm) ->get();
this returns nothing, when directly replace quotation mark with
... against('$searchterm*' in boolean mode) ...
then results correct. however, if do
db::getquerylog();
i get
"query" => "select `user_id`, match(first_name, last_name) against('?*' in boolean mode) search_score `userprofile`" "bindings" => array:1 [ 0 => "random word" ]
so it's if bindings should added, they're not. have tried variations of select, selectraw, ->setbindings, ->addbinding($searchterm, ['select']) etc. have been suggested elsewhere. how can make these bindings work?
did try replacing whole regex this?
$searchterm = 'random word*'; $subquery = db::table('userprofile')->selectraw(" user_id, match(first_name, last_name) against(? in boolean mode) search_score ") ->addbinding($searchterm) ->get();
this way maybe quotes not added if laravel adds them.
Comments
Post a Comment