$goodsShow = Goods::where('product_id','=',$id)->first();
这个是 查询一个条件呢 我想在where 里面 在增加 几个条件 可以吗
有大神指点一下吗
$goodsShow = Goods::where('product_id','=',$id)->first();
这个是 查询一个条件呢 我想在where 里面 在增加 几个条件 可以吗
有大神指点一下吗
多条件的话可以这样写:
$goodsShow = Goods::where('cate_id','=',$cate_id)
->where(function($query){
$query->where('status','<','61')
->orWhere(function($query){
$query->where('status', '91');
});
})->first();
这一段其实执行的就是where cate_id = $cate_id AND (status < 61 OR status = 91)
$sql = "select * from user where uid = pid or uid = cid";
$re = M('user')->query($sql);
$goodsShow = Goods::where([
'a' => '1',
'b' => '2',
])->first();
也可以定义一个数组,然后以参数的形式传给where
$array = [
'' => '',
'' => '',
];
$goodsShow = Goods::where($array)->first();
也可以用
orWhere()
2 回答2.5k 阅读✓ 已解决
2 回答1.1k 阅读✓ 已解决
1 回答851 阅读✓ 已解决
2 回答525 阅读✓ 已解决
944 阅读
2 回答566 阅读
1 回答685 阅读
$goodsShow = Goods::where([product_id'=>$id,'name'=>$name])->first();