我想从只有1个id_product的mySQL中获取数据,所以当有2个数据具有相同的id_product值时。它只得到了第一个。我已经尝试了在mySQL中的查询和它的工作,查询如下
select `product_photo`.*, `product`.`id_merchant` from `product_photo` inner join `product` on
`product_photo`.`id_product` = `product`.`id` where `product`.`id_merchant` = 11 group by
`product_photo`.`id_product` 但是当我在我的laravel控制器上实现它时,我得到了错误,代码是这样的
$id_merchant = $request->input('id_merchant');
$photo=DB::table('product_photo')
->join('product','product_photo.id_product','=','product.id')
->select('product_photo.*','product.id_merchant')
->where('product.id_merchant','=',$id_merchant)
->groupBy('product_photo.id_product')
->get();
return response()->json(['success'=>true,'message'=>'success', 'data' => $photo],200);有没有人能告诉我为什么我的小腹出错了?对不起,我的英语
发布于 2021-02-06 16:33:44
这是由MySQL的严格模式引起的。在config/database.php文件中将strict更改为false。
打开文件时,在mysql数组中设置strict => false。禁用MySQL的严格模式后,它应该不会再显示错误。
https://stackoverflow.com/questions/66074721
复制相似问题