php CodeIgniter 3 无法找到您指定的模型
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30420747/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
CodeIgniter 3 Unable to locate the model you have specified
提问by sthiago
I'm getting this error:
我收到此错误:
Unable to locate the model you have specified: Users_model
CodeIgniter is version 3. The filename is Users_model.php
. It is located at application\models
and it goes like this:
CodeIgniter 是版本 3。文件名为Users_model.php
. 它位于,application\models
它是这样的:
defined('BASEPATH') OR exit('No direct script access allowed');
class Users_model extends CI_Model {
public function __construct()
{
parent::__construct();
}
[...]
}
I am calling it from a controller like this:
我从这样的控制器调用它:
$this->load->model('users_model');
Interestingly enough, it works on a local mongoose server, but not when I deploy it to a heroku server.
有趣的是,它可以在本地猫鼬服务器上运行,但在我将其部署到 heroku 服务器时就不行了。
采纳答案by sthiago
Your git maybe configured to ignore case changesin file names. The effect of this is: any local changes to a filename of a file that has already been deployed(i.e. is only being modified) are not mirrored on the remote repository (heroku).
您的 git可能配置为忽略文件名中的大小写更改。这样做的效果是:对已部署(即仅被修改)的文件的文件名的任何本地更改都不会反映在远程存储库 (heroku) 上。
For example, if you first deployed a file with the name users_model.php
all lowercase. Even if you change the local version of the file to Users_model.php
with the 'U' capitalized, the remote won't mirror this change.
例如,如果您首先部署了名称users_model.php
全部小写的文件。即使您将文件的本地版本更改为Users_model.php
“U”大写,遥控器也不会反映此更改。
How to solve it: to tell git to update filename case changes, run the following command:
git config core.ignorecase false
如何解决:要告诉 git 更新文件名大小写更改,请运行以下命令:
git config core.ignorecase false
Thanks to @Kamram for making me figure this out and @FeanDoe for suggesting that I answer the question.
感谢@Kamram 让我弄清楚这一点,感谢@FeanDoe 建议我回答这个问题。
回答by Abdulla Nilam
Try this.
尝试这个。
- In your model file nameshould be
users_model.php
. inside modelit should be (Users_Model)
class Users_Model extends CI_Model{}
.When you calling use
$this->load->model('Users_Model');
- 在你的模型文件名应该是
users_model.php
. 内部模型应该是(Users_Model)
class Users_Model extends CI_Model{}
.当你打电话使用
$this->load->model('Users_Model');
回答by Amit
in folder "application/models"you should change your file name from "users_model.php"to "Users_model.php"
在文件夹“application/models”中,您应该将文件名从“users_model.php”更改为“Users_model.php”