错误
遇到未捕获的异常类型:RuntimeException消息: 无法找到您指定的模型:事件文件名: /home/dailysurvive/public_html/citymallgulberglahore.com/mall/system/core/Loader.php 行号:344 Backtrace:文件: /home/dailysurvive/public_html/citymallgulberglahore.com/mall/application/controllers/Welcome.php 行:29功能:模型文件: /home/dailysurvive/public_html/citymallgulberglahore.com/mall/index.php 行:315功能:require_once
错误文件的图像如下
Model.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;
}
}
Loader.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;
}
的welcome.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);
的index.php
/*
* --------------------------------------------------------------------
* LOAD THE BOOTSTRAP FILE
* --------------------------------------------------------------------
*
* And away we go...
*/
require_once BASEPATH.'core/CodeIgniter.php';
答案 0 :(得分:0)
1:将您的模型名称从Events.php重命名为Events_model.php 2:使用$ this-> load-> model('Events_model','events')