Codeigniter的奇怪问题(型号问题)


Weird Issue with Codeigniter (Model Issue)

我已经在linux机器上设置了CodeIgniter的本地副本和另一个副本。在我的应用程序中安装了两个副本后,本地副本运行良好,但linux版本显示以下错误代码:

Unable to locate the model you have specified: User_model

我找了一整天这个问题的答案。我试着更改了模型名称、文件名以及我能想到的所有内容的拼写。我可能缺少什么来显示错误?

谢谢各位

这是我的代码副本:

(user_model.php)

 <?php
class User_model extends CI_Model {
    public function __construct(){
        parent::__construct();
    }
    function runTest(){
        return "Testing";
    }
}
?>

(welcome.php)

class Welcome extends CI_Controller {
public function __construct(){
    parent::__construct();
}
public function index()
{
    $this->load->model('User_Model');
    $data['testing'] = $this->user1234->runTest();
    $this->load->view('welcome_message', $data);
}

}

这是因为区分大小写。首先,您应该将所有文件名用小写字母表示(user_model.php),然后在控制器中使用该名称($this->load->model('user_model');)。

它必须起作用。

感谢大家的帮助。显然,这是一个命名问题。我将文件名大写,在控制器中,它现在运行得很好。不知道这是怎么回事。但非常感谢你们。

新代码如下:

$this->load->model('User_model');
$query = $this->User_model->validate();
     $this->load->model('User_Model');
    $data['testing'] = $this->user1234->runTest();
    $this->load->view('welcome_message', $data);

你的第二行有错误将其更改为

$data['testing'] = $this->user_model->runTest();