繁体   English   中英

我如何选择状态= 0而不是同时使用laravel

[英]how do i select where status = 0 and not both with laravel

我正在尝试使用以下示例从DB :: table中选择信息

Table::where('status', 1)
      ->where('senderid', myid)
     ->orWhere('recevrid', myid)
     ->get();

我希望此脚本选择status = 1的行,但也返回状态甚至为零的结果。.能帮我一个让我只选择status = 1和0的地方吗?

这样使用嵌套查询

$query = Table::where('status', 1);
$query->where(function($query) use($myid){
    $query->orWhere('senderid', $myid);
    $query->orWhere('recevrid', $myid);
});
$result = $query->get();

尝试

Table::where([['status','=', 1],['senderid','=', myid]])
     ->orWhere([['status','=', 1],['recevrid','=', myid]])
     ->get();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM