遇到未捕获的异常 类型:运行时异常消息:找不到指定的模型:事件



error

遇到未捕获的异常 类型:运行时异常消息: 无法找到指定的模型:事件文件名:/home/dailysurvival/public_html/citymallgulberglahore.com/mall/system/core/Loader.php 行号:344 回溯: 文件:/home/dailysurvival/public_html/citymallgulberglahore.com/mall/application/controllers/Welcome.php 行:29 功能:模型文件:/home/dailysurvival/public_html/citymallgulberglahore.com/mall/index.php 行: 315 功能: require_once

错误文件的图像如下

型号.php

defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Model Class
*
* @package     CodeIgniter
* @subpackage  Libraries
* @category    Libraries
* @author      EllisLab Dev Team
* @link        https://codeigniter.com/user_guide/libraries/config.html
*/
class CI_Model {
/**
* Class constructor
*
* @return  void
*/
public function __construct()
{
log_message('info', 'Model Class Initialized');
}
// --------------------------------------------------------------------
/**
* __get magic
*
* Allows models to access CI's loaded classes using the same
* syntax as controllers.
*
* @param   string  $key
*/
public function __get($key)
{
// Debugging note:
//  If you're here because you're getting an error message
//  saying 'Undefined Property: system/core/Model.php', it's
//  most likely a typo in your model code.
return get_instance()->$key;
}

}

装载机.php

$model = ucfirst($model);
if ( ! class_exists($model, FALSE))
{
foreach ($this->_ci_model_paths as $mod_path)
{
if ( ! file_exists($mod_path.'models/'.$path.$model.'.php'))
{
continue;
}
require_once($mod_path.'models/'.$path.$model.'.php');
if ( ! class_exists($model, FALSE))
{
throw new RuntimeException($mod_path."models/".$path.$model.".php exists, but doesn't declare class ".$model);
}
break;
}
if ( ! class_exists($model, FALSE))
{
throw new RuntimeException('Unable to locate the model you have specified: '.$model);
}
}
elseif ( ! is_subclass_of($model, 'CI_Model'))
{
throw new RuntimeException("Class ".$model." already exists and doesn't extend CI_Model");
}
$this->_ci_models[] = $name;
$CI->$name = new $model();
return $this;
}

欢迎光临.php

public function index($data=null)
{
//$this->load->view('welcome_message');
$this->load->model("events");
$data['records'] = $this->events->getAllRecords();

$this->load->view('header',$data);
$this->load->view('home',$data);
$this->load->view('footer',$data);
}
function home()
{
$data = array(
'back_step' => '../',
);

$dat = array(
'email'     => $this->input->post('email')
);

$this->load->model("events");
$this->load->database();
$res = $this->db->insert('subscribe',$dat);
$data['records'] = $this->events->getAllRecords();
$this->index($data);

索引.php

/*
* --------------------------------------------------------------------
* LOAD THE BOOTSTRAP FILE
* --------------------------------------------------------------------
*
* And away we go...
*/
require_once BASEPATH.'core/CodeIgniter.php';

1:将模型名称从 Events.php 重命名为 Events_model.php 2:使用$this->加载>模型("Events_model","事件")

最新更新