所以我有这个代码
$Input = Input::all();
$makethis = Input::flash();
$soptions = Input::get('soptions');
$items = Gamefarm::where('roost_hen', '=',Input::get('sex'))
->where('bname', 'LIKE', '%$soptions%')
->paginate(6);
我想做的是让 laravel 接受$soptions
内部的值。当我尝试对$soptions
进行硬编码时,它工作正常。
还有一个问题
$Input = Input::all();
$makethis = Input::flash();
$textbox = Input::get('searchbox');
$soptions = Input::get('soptions');
var_dump($soptions);
$items = Gamefarm::where('roost_hen', '=', Input::get('sex'))
->where($soptions, 'LIKE', "$textbox")
->paginate(6);
return View::make('gamefarms/index', compact('items','makethis'));
现在我想做的是使用变量$soptions
作为查询的字段名称,当我这样做时我得到一个错误 500
这个'%$soptions%'
不会值,相反,你应该写"%$soptions%"
或"%{$soptions}%"
或'%' . $soptions . '%'
。简单的错误。