Answer the question
In order to leave comments, you need to log in
Why doesn't Yii2 return all fields on JeftJoin?
Hey! I'm trying to get the required fields:
return $this->hasMany(FileUsage::className(), ['usage_id' => 'id'])
->select('f.id, f.user_id, f.type_id, f.name, f.mime, f.size, fu.usage_id')
->alias('fu')
->leftJoin('file f', 'f.id = fu.file_id')
->where(['in', 'f.type_id', $fileTypes])
->andWhere(['fu.is_deleted' => FileUsage::IS_NOT_DELETED])
->orderBy(['fu.id' => SORT_DESC])
->limit(1);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question