CakePHP executes method names as SQL queries

℡╲_俬逩灬. 提交于 2019-12-11 04:06:12

问题


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() { }

Now when I navigate to users/index I get the following error:

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

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?


回答1:


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.



来源:https://stackoverflow.com/questions/7382597/cakephp-executes-method-names-as-sql-queries

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!