Reputation: 1275
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 in a single view page.
Upvotes: 1
Views: 1310
Reputation: 3998
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/
Upvotes: 1
Reputation:
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
.
Upvotes: 1
Reputation: 2469
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 !
Upvotes: 0