CakePHP executes method names as SQL queries
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_func开发者_C百科tion();
$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?
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.
精彩评论