This is the main.php content:
'import' => array(
'application.models.*',
'application.modules.admin.models.*',
'application.components.*',
),
where admin is a module. In the controller index function I have this:
$model = Users::model('search');
Where Users is a model class inside the admin module I get this error message:
include(Users.php): failed to open stream: No such file or directory
How do i call a model from a module in my controller ?
尝试使用以下命令将模块加载到控制器中:
Yii::app()->getModule('Admin');
In your main.php file register your admin module. Link here
return array(
........,
'import' => array(
'application.models.*',
'application.modules.admin.models.*',
'application.components.*',
),
'modules' => array( // Add your new modules here.
"admin"=>array()
)
....
);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.