开发者

How to fetch the data in Yii Multi Model Form?

I am the new user of Yii Framework, Now I have created a multi model for table 'A' and table 'B' in yii, here I save the data successfully into this two table, now I have problem to fetch the data in this two table i开发者_StackOverflow中文版n a single view page.


You just pass in the two models to the view function:

$a_criteria = new CDbCriteria...
$b_criteria = new CDbCriteria...
$a = MyModel::model()->find($a_criteria);
$b = MyOtherModel::model()->find($b_criteria);

$this->render('view', array(
        'a'=>$a,
        'b'=>$b,
    ));

Then in your view you can reference $a and $b.


use this wiki.. its really useful. this solves your problem

http://www.yiiframework.com/wiki/19/how-to-use-a-single-form-to-collect-data-for-two-or-more-models/


Hey you need to fetch one model only. But the other model should be related with relations function and then the other one will automatically be fetched.

Remember Blog Comment example from Yii demo !

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜