Laravel 框架与 SQL where-in 冲突

Laravel framework is clashing with SQL where-in

使用Laravel框架。看起来 Where-In sql 查询与框架冲突。我错了吗,如果没有任何解决方法?

    //terms is the search string sent to server. 
    //Am breaking it up into searchable tags.
    $terms = explode(" ", $term);

    $posts = DB::select('SELECT * FROM car
    WHERE model IN ?',
    implode(',',$terms));

错误:

prepareBindings() must be of the type array, string given

你能试试吗 $posts = DB::select('SELECT * FROM car WHERE model IN (?)', [implode(',',$terms)]); 并报告

我更新了答案以反映对您有用的答案。