Codeigniter 3-无法找到您指定的模型 [英] Codeigniter 3 - Unable to locate the model you have specified
问题描述
我知道平台上针对此问题的其他问题,但是与此同时,我遇到了一个非常不寻常的问题.
我有一个模型 Company_Model.php
,该模型正在自动加载到 autoload.php
中,并且该类的构建如下:
Class Company_Model扩展了CI_Model {函数__construct(){父母:: __ construct();}公共功能foo(){回声'酒吧';}}
但是,我在加载页面时仍然出现此错误:
我在Ubuntu 14.04上的Apache 2,PHP 5.5.9上运行,找不到此问题的错误日志,现在我很困惑,将不胜感激地收到任何帮助.
我已经检查了Stackoverflow的大写字母和所有其他提示,但仍然不满意.
编辑
自动加载代码
$ autoload ['model'] = array('company_model');
使用codeigniter 3时,必须确保类名和文件名仅具有首字母大写,如此处所述
类命名样式指南 >
<?phpclass Company_model扩展CI_Model {}
然后文件名应为 Company_model.php
$ autoload ['model'] = array('company_model');
如果在子文件夹中
模型>子文件夹> Company_model.php
$ autoload ['model'] = array('subfolder/company_model');
如果仅需要在控制器上调用
$ this-> load-> model('company_model');$ this-> company_model-> function();
子文件夹
$ this-> load-> model('subfolder/company_model');$ this-> company_model-> function();
I am aware of the other questions on the platform for this issue however I am having a very unusual issue with this.
I have a model Company_Model.php
which is being autoloaded in the autoload.php
and the Class is built like this:
Class Company_Model extends CI_Model {
function __construct()
{
parent::__construct();
}
public function foo()
{
echo 'bar';
}
}
However I am still getting this error when I load the page:
I am running on Apache 2, PHP 5.5.9 on Ubuntu 14.04, I cannot find an error log for this issue and now I am baffled, any help would be gratefully recieved.
I have check the uppercasing and all of the other tips from StackOverflow but still no joy.
Edit
Auto load code
$autoload['model'] = array('company_model');
When you use codeigniter 3 you have to make sure your class names and file names only have the first letter upper case as explained here
<?php
class Company_model extends CI_Model {
}
And file name then should be Company_model.php
$autoload['model'] = array('company_model');
If in sub folder
models > sub folder > Company_model.php
$autoload['model'] = array('subfolder/company_model');
If need to call it on controller only
$this->load->model('company_model');
$this->company_model->function();
Sub folder
$this->load->model('subfolder/company_model');
$this->company_model->function();
这篇关于Codeigniter 3-无法找到您指定的模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!