2014-02-23 56 views
0

故障讓代碼點火器與我的模型工作中發現...致命錯誤:類 '型號 CI_Model' 不

文件1: user_model.php

class User_Model extends CI_Model { 

var $idUsers; 
var $Email; 
var $Password; 
var $CreatedAt; 

function __construct() 
{ 
    parent::_construct(); 
} 
} 

文件2: 自動加載.PHP

$autoload['model'] = array('User_model'); 

的錯誤: 致命錯誤:類 '型號\ CI_Model' 在/home/.../application/models/user_model.php沒有發現第5行...

問題似乎CI_Model不存在於模型中,它存在於其他地方。系統\核心\ Model.php

我使用笨2.1.4

我不知道什麼是錯這個......?

+0

'父:: _結構( );'應該是'parent :: __ construct();'(兩個下劃線)。這是一個錯字嗎? – Samutz

+0

我加了雙__但仍然是相同的錯誤。 – user3247921

+1

您可以包含整個模型代碼,或者至少包含user_model的第5行的內容嗎? – Samutz

回答

2

你的自動加載是錯誤的

$autoload['model'] = array('User_model'); 

應該

$autoload['model'] = array('User_Model'); 

和你的構造應該是

parent::__construct(); 
0

型號名稱不符合correct convention

Class names must have the first letter capitalized with the rest of the name lowercase.

所以:

class User_Model extends CI_Model 

應該是:

class User_model extends CI_Model 
2

控制器和模型必須在不同的名稱。

0

!!! '自動加載'在某些模型中出現問題,我沒有使用'自動加載'。

第一州:

1. image Error

我解決方法:(我感動,這個問題有所改善)

Result

相關問題