我是laravel查询构建器的新手,我想搜索在输入字段中输入的多个单词,例如,如果我输入"jhon doe"我想要获取包含jhon或doe的任何列
我已经看过/尝试使用php MySQL的解决方案,但无法适应查询构建器
//1. exploding the space between the keywords
//2. using foreach apend the query together
$query = "select * from users where";
$keywordRaw = "jhon doe";
$keywords = explode(' ', $keywordRaw );
foreach ($keywords as $keyword){
$query.= " first_name LIKE '%" + $keyword +"%' OR ";
}
Run Code Online (Sandbox Code Playgroud)
如何使用查询生成器执行此操作
这就是我到目前为止,这样做的正确方法是什么,
$keywordRaw = "jhon doe";
//how do I explode this words and append them along with their appropriate query
$users = User::select('users.*')
->where('first_name', 'LIKE', '%'.$keywordRaw.'%')
Run Code Online (Sandbox Code Playgroud)
请帮助,提前谢谢
您好,我如何获得分数的最大值,其中列ID范围从3-5示例表开始

我想获得分数的最大值,其中列ID范围从3-5,请帮忙,
到目前为止我做了什么:
$max_scores_table= DB::table('scores_table')
->where('id', '>', 2)
->max('score');
Run Code Online (Sandbox Code Playgroud)
另一个问题是,当我使用max()函数时,表中有一个小数点,它得到ID = 5,得分为4.5,而不是ID = 4,值为4.6,tnx提前