我有一个给我错误的查询
$query= DB::table('crm_listings as l')
->leftJoin('crm_location as loc', 'l.area_location_id', '=', 'loc.loc_id')
->select('l.id','l.name','l.price', 'loc.lat', 'loc.lon')
->get();
foreach($query as $i=>$p) {
$images_query =DB::table('crm_listings_images')->where('listing_id', $p['id'])->select('image')->get();
$query[$i]['images'] = $images_query;
}
return $query;
错误是Cannot use object of type stdClass as array
我有这些问题
- 这是一个很好的方法吗?或者我们可以改进它?
- 如何解决此错误?