2.0下Class 'Model' not found,但1.7正常
首先我是小菜鸟,这个问题可能是哪里没设好所遭成的!怀着兴奋的心情,下了个新版2.0试用,刚按教程编了一个简单例子
(是按上面操作的http://www.ibm.com/developerworks/cn/web/wa-codeigniter/index.html)
页面出来,心情激动,但是当提交,就显示
Fatal error: Class 'Model' not found in E:\xampp\htdocs\cg88\application\models\mcontacts.php on line 8
(本地环境是xammp1.7)
mcontacts.php 如下:
<?php
class MContacts extends Model{
function MContacts(){
parent::Model();
}
function addContact(){
$now = date("Y-m-d H:i:s");
$data = array(
'name' => $this->input->xss_clean($this->input->post('name')),
'email' => $this->input->xss_clean($this->input->post('email')),
'notes' => $this->input->xss_clean($this->input->post('notes')),
'ipaddress' => $this->input->ip_address(),
'stamp' => $now
);
$this->db->insert('contacts', $data);
}
}
?>
经过一番查错,对照,还是没找到问题根源,百度,谷歌就找到一个类似的先例,还是也没解救的方法,,
http://codeigniter.org.cn/forums/viewthread.php?tid=4268&page=1
无奈之下,我还是用旧的版本,1.73,旧版本就没有出错,,不知为什么,,跪求:'( 请看2.0的手册 Model 部分 :handshake 解决,看教程不细心,,,谢谢
模型类文件存放在 application/models/ 文件夹。 如果你愿意,可以在里面建立子文件夹。
最基本的模型类必须像这样:
class Model_name extends CI_Model {
function __construct()
{
parent::__construct();
}
} 不对啊 我还是出现这个问题! 2.0应该集成的应该是CI_Model:
class MContacts extends Model{
改成class MContacts extends CI_Model{
另外构造函数好像也要改一下,看一下用户手册
页:
[1]