balajis
(Balajisankar)
1
I am trying to access a module’s model from another module ,
ex:
protected/modules/module1/DefaultController
protected/modules/module2/DefaultController
i want to access module1 models from module2 ,
i tried
Yii::app()->getModule(‘module1’);
$m = new module1;
it showing the error
include(module1.php): failed to open stream: No such file or directory
add in your file
Yii::import('applications.modules.module1.*')
balajis
(Balajisankar)
3
thank you nawin
if i want to access module1 models any idea
Yii::import(‘applications.modules.module1.*’)
module1= new module1;
is this correct ,
module1 having models name is site
public static function getAssignData(){
$assigndata = Yii::app()->db->createCommand()
->selectDistinct('name')
->from('table1')
->queryAll();
return $assigndata;
}
i want to access getAssignData() in module2 view page
Yii::import('application.modules.module1.models.*');
$module1=new module1;
$model= module1::model()->findByPk($id);
$this->render('view',array(
'model'=>$this->loadModel($id),
'module1'=>$module1,
));