开发者

Multi Level Relationships and Models in Yii

开发者 https://www.devze.com 2023-04-10 19:43 出处:网络
How do I get the model of relationships? (and then the models of those relation开发者_如何学运维ships)

How do I get the model of relationships? (and then the models of those relation开发者_如何学运维ships)

Maybe something like below, but im stuck:

$model = Store::model()->findByPk($_GET['id']);

$relation = $model->getMetaData();

$relation = $relation->relations;

foreach($relation as $name=>$relation){

  $model_of_relation = ??;

}


Try something like this:

$model = Store::model()->findByPk($_GET['id']);
foreach($model->relations as $relatedModel) {
    $model_of_relation = $model->getRelated($relatedModel);
    // ... Other processing of $model_of_relation ...
}
0

精彩评论

暂无评论...
验证码 换一张
取 消