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 !
精彩评论