orWhere vs Where Laravel 5.1

后端 未结 2 1483
攒了一身酷
攒了一身酷 2020-12-11 22:39

I have the following code:

$results = \\DB::table(\'pack\')
            ->Join(\'users as u1\', \'u1.id\', \'=\', \'pack.userid\')
            ->Join(\         


        
2条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-11 23:04

    If your database row matches any of the orWhere it will show the row. In your code you have

    ->orWhere('pack.description', 'LIKE', "%$text%")
    ->orWhere('pack.skills', 'LIKE', "%$text%")
    ->orWhere('s1.name', 'LIKE', "%$text%")
    

    If you row matches any of them it will ignore other where or orWhere

提交回复
热议问题