Laravel - 如何在 where 子句中编写多个条件?

标签 laravel laravel-5 laravel-5.3

实际上我的查询是:

SELECT * FROM company WHERE status<>$status AND type=$b1 AND type=$b2

如何在 Laravel 中转换它?

我在 laravel 中做了这个,但它不起作用:

$data['Company'] = DB::table('company')->where([["status","<>",$status], ["type","=",$b1],["type","=",$b2]])->get();

请帮助我!

最佳答案

whereIn 方法验证给定列的值是否包含在给定数组中:

$data['Company'] = DB::table('company') ->where('status','<>',$status) ->whereIn('type',['$b1','$b2') ->get();

关于Laravel - 如何在 where 子句中编写多个条件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45957133/

相关文章:

php - laravel 5.1 - 从 2 表中检索数据并使用 foreach 将其发送到索引页

laravel - 如何在laravel eloquent中从多个表中检索数据

rest - Laravel 5.3 REST中的JSON验证错误消息

php - laravel3 中的路由无法正常工作

php - Laravel whereIn 数组

php - Laravel 的 Eloquent public static function "create"在 Model.php 中发生了什么?

php - &lt;textarea&gt; 无法在 laravel 中发布值

php - 如何将请求实例从一个 Controller 函数传递到另一个 Controller 函数

使用 JWT Auth 时 Laravel 5.3 节流登录

php - Laravel Carbon 入门 + 本周末