开发者

Multi Level Relationships and Models in Yii

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜