这是我的原始查询
$searchData=DB::select('SELECT * FROM hostretreats WHERE (furnishing_type= "'.$typesearchkeyword.'" OR prop_type="'.$typesearchkeyword.'") AND approved = 1');
请帮助我如何解决它?
答案 0 :(得分:1)
您应该使用数据库方法重写select查询。
$searchData = DB::table('hostretreats')
->where(function($query) use ($typesearchkeyword){
$query
->where('furnishing_type', $typesearchkeyword)
->orWhere('prop_type', $typesearchkeyword);
})
->where('approved', 1)
->paginate(10);