问题描述
我在本地开发CakePHP网站。我创建了一个UserController使用的User模型。一切都在我的盒子上正常工作,但一旦我检查出我的主机上的代码(WebFaction)CakePHP开始尝试执行用户模型中的方法的名称作为SQL查询。
I am developing a CakePHP site locally. I created a User model that is used by the UsersController. Everything works fine on my box, but as soon as I check out the code on my host (WebFaction) CakePHP starts trying to execute the names of methods in the User model as SQL queries.
# users_controller.php
public function index() {
$this->User->dummy_function();
$users = $this->User->find('all');
$this->set(compact('users'));
}
# User.php
public function dummy_function() { }
现在当我导航到users / index我得到以下错误:
Now when I navigate to users/index I get the following error:
警告(512) 1064:您的SQL语法中有错误;检查与您的MySQL服务器版本对应的手册,以获得在第1行[core / cake / libs / model / datasources / dbo_source.php,第684行]附近的'dummy_function'使用的正确语法
查询CakePHP执行的是 dummy_function
Warning (512): SQL Error: 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'dummy_function' at line 1 [CORE/cake/libs/model/datasources/dbo_source.php, line 684]
and the query that CakePHP executes is dummy_function
这就是框架找不到我的用户模型,与此相关,但我已经在此服务器上部署CakePHP应用程序,从来没有这个问题。我使用CakePHP 1.3.11。任何想法?
It follows that the framework cannot find my User model and that my host has something to do with this, but I have deployed CakePHP apps on this server before and never had this problem. I'm using CakePHP 1.3.11. Any ideas?
推荐答案
这是我在Windows上开发。不要是傻瓜。确保您的型号名称都是小写。虽然我希望CakePHP警告我,它找不到模型。
That's what I get for developing on Windows. Don't be a fool. Make sure your model name is all lowercase. Though I wish CakePHP warned me that it couldn't find the model.
这篇关于CakePHP将方法名称执行为SQL查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!