Laravel,Lumen,多字段使用where in 查询

public function verifyCalorieGoods(array $goodsInfo)
{
        //拼接多字段where in raw查询语句
        $raw = '(goods_id,attr_symbol_path) IN (';
        foreach ($goodsInfo as $v){
            $symbol = empty($v['attr_symbol_path']) ? '' : $v['attr_symbol_path'];
            $raw .= "({$v['goods_id']},'{$symbol}'),";
        }
        $raw = rtrim($raw,',');
        $raw .= ')';

        //数据查询
        $data = $this->calorieGoods::query()
            ->whereRaw($raw)
            ->get(['goods_id'])
            ->toArray();
}

你可能感兴趣的:(Laravel,Lumen,多字段使用where in 查询)