Answer the question
In order to leave comments, you need to log in
How to merge yii2 models?
I am using yii2. There are 2 tables, conditionally user(id,address,...) and profile(id,user_id,...) 1: n. The user table has data, such as an address, that pertains to each user profile. Created through gii 2 ActiveRecords models. In the controller I call the static function Profile::getProfiles(condition)
function static getProfiles(condition){
return self::find()->where(condition)—>all();
}
Answer the question
In order to leave comments, you need to log in
1) You don't need a static function here. We read about connections - commercito.ru/hasone-hasmany-svyazannye-dannye-vy... .
2)
- what is this action? if the address is updated, then make a request to ActiveRecord.
Otherwise, use getAddress, the magic field, with respect to hasOne on the user table.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question