加载CI_Model失败
刚开始学习CI,当头一棒,报错如下:Fatal error: Class 'CI_Model' not found in /usr/local/apache2/htdocs/ci/application/models/hello_model.php on line 3A PHP Error was encounteredSeverity: Error
Message: Class 'CI_Model' not found
Filename: models/hello_model.php
Line Number: 3
Backtrace:
model代码如下:
<?php
class Hello_model extends CI_Model {
function __construct()
{
print_r("111111111111111111");
parent::__construct();
}
function findData()
{
$query = $this->db->get("t_user",10);
return $query->result();
}
}
求助各位大神 本帖最后由 aneasystone 于 2015-7-4 17:59 编辑
按理说CI_Model应该会自动加载的,如果出现CI_Model加载失败的错,很有可能是路径配置有问题。
检查下APPPATH和BASEPATH是否正确。
可以在/system/core/Common.php文件的&load_class()方法中加入两句调试信息,如下:
// Look for the class first in the local application/libraries folder
// then in the native system/libraries folder
foreach (array(APPPATH, BASEPATH) as $path)
{
if (file_exists($path.$directory.'/'.$class.'.php'))
{
$name = 'CI_'.$class;
if (class_exists($name, FALSE) === FALSE)
{
// 应该会打印出system/core/Model.php
echo $path.$directory.'/'.$class.'.php' . "<br>";
require_once($path.$directory.'/'.$class.'.php');
}
break;
}
}
echo $name . "<br>"; // 应该会打印出CI_Model
aneasystone 发表于 2015-7-4 17:56
按理说CI_Model应该会自动加载的,如果出现CI_Model加载失败的错,很有可能是路径配置有问题。
检查下APPPA ...
这里打印确实没有model。谢谢!
页:
[1]