php - Laravel select() don't work with params when they have spaces -
i have simple part of code:
$r=input::get('r'); $sql='select * `table` `name`=?'; $dis=\db::connection('old-dis')->select($sql, [$r]); when $r don't has spaces, works corretly. when $r simple teddy bear laravel show me error , doesn't add ' ' text. find next solution:
if(strpos($r,' ')) $r="'$r'"; anyone has better way fix it?
this should work better.
$r=input::get("r"); $results = db::connection('old-dis') ->select( db::raw("select * table name = :variable"), [ "variable"=>$r, ]); dd($results);
Comments
Post a Comment