Yii,从主app控制器

时间:2015-06-09 11:15:15

标签: php yii module

我想在主应用控制器的 booksImported 模块中加载模型,

main.php

    'import'=>array(
    'application.models.*',
    'application.components.*',
            'application.modules.booksCategory.models.*', 
            'application.modules.booksImported.models.*' 
         ),

在我的SiteController函数中,我试过..

Yii::app()->getModule('Importedbooks')

这只获取模块名称。我也试过

       Yii::setPathOfAlias('booksImported','../modules/booksImported/models');

        Yii::import('booksImported.models.Importedbooks',true);  // this will include the class DesiredModel immediately

        $model = Yii::createComponent('Importedbooks');

        print_r($model);

给出错误

Alias "booksImported.models.Importedbooks" is invalid. Make sure it points to an existing PHP file and the file is readable.

0 个答案:

没有答案