Hii there,
I’m trying to obtain a count of comments, but need to only get those whose user accounts are “normal” (rec_status = 1
)
For that, I have this piece of code:
->contain([
'Users',
'ClipsComments' => function($q) {
return $q->select([
'counter' => $q->func()->count('id'),
'clip_id'
])
// here there be error
->innerJoinWith('Users', function(Query $q) {
return $q->where(['Users.rec_status' => 1]);
})
->group(['ClipsComments.clip_id'])
->where(['ClipsComments.rec_status' => 1]);
}
])
The problem here is, that since both Users
and ClipsComments
have a field id
, it throws the error Column 'id' in field list is ambiguous
.
My question is, how would I get around this issue?