我希望在我的网站上进行自定义搜索。
这是 MySQL 搜索:
选择*从MyDB
.MyTable
WHERE (id
喜欢“%MySearch%”或firstname
喜欢“%MySearch%”或lastname
喜欢“%MySearch%”或email
喜欢“%MySearch%”或address
像'%MySearch%');
我如何才能将搜索输入到我的 Laravel 控制器中?
$users = DB::table('MyTable')->where('firstname', 'MySearch')->get();
我的 Laravel 控制器 https://i.stack.imgur.com/Rzmcv.png
提前致谢 !
$users = DB::table('MyTable')
->where('id', 'LIKE', '%MySearch%')
->or_where('firstname', 'LIKE', '%MySearch%')
->or_where('lastname', 'LIKE', '%MySearch%')
->or_where('email', 'LIKE', '%MySearch%')
->or_where('address', 'LIKE', '%MySearch%');
->get();
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)