Hello,
I have been using Yii2 for a few months now and I have a question. Since Yii2 has a unique feature to generate model (Gii) which extends \yii\db\ActiveRecord, I am wondering if calling conditionals, join, order by and group by from Controller violates the MVC rule?
For example, if I call this from Controller :
$model = VisitorData::find()
->alias(‘a’)
->joinWith(‘iDVISITOR’) //relation generated by Gii
->where([
‘TYPE’=>‘NEW VISITOR’
])
->andWhere([’<>’, ‘a.ID_STATUS’, ‘3’])
->orderBy([‘a.NAME’=>SORT_ASC])
->all();
Will that violate the MVC rule?(I should put that snippet in a function within VisitorData Model) or is it okay since I did not build the query from scratch?
Hoping for feedbacks.
Thanks!