Closed
Description
with this query:
//photos
$query = PicTag::select(DB::raw('DISTINCT(pic_id)'),'users.username','users.displayname')
->join('pics', 'pics.id', '=', 'pic_tag.pic_id')
->join('users','users.id','=','pics.user_id')
->whereIn('tag_id', $tagids);
dd($query->count());
if($cat)
$query->where('typ',$cat);
if($year)
$query->where('jahrprod',$year);
$pics = $query->orderBy('pics.id','desc')
->paginate(30);
dd($query->count());
tells me I have 587 items. But when I execute the query in mysql CLI, I get 585 items. Also, the view shows 585 photos. (unless I remove the distinct
--> then I get 587)
$pics->getTotal()
does also count 587 items. That is, because some 'photos (pics)' have 2 'tags' with the same letters and get double listet, when querying without DISTINCT
or doing ->groupBy('pics.id')
So I think something could be wrong with the collection or count()
.(?)