开发者

Controller not found in cakePHP

I have controller class EmployeeController in employee_controller.php file,and i have a model class Employee in employee.php ,database table is employees ,All the functions are working (such as findall() and read() are working fine),but i have add function which is like this

    function add() {
        if (!empty($this->data)) {
        if ($this->Employee->save($this->data)) {
        $this->Session->setFlash('Employee has been saved.');
        $this->redirect(array('action' => 'index'));
            }

When i tried to save ,An error EmployeesController not found will display and shows the following code

<?php
class EmployeesController extends AppController {
    var $name = 'Employees';
}
?>

i am not able 开发者_开发技巧to solve this problem ,please help me out to get rid of this problem


The file should be called employees_controller.php, not employee_controller.php.

All controller files are named in the plural.


You can also learn about the naming of the tables and the conventions at http://cakeapp.com


I don't know if the question is still important, but the cakephp convention says that filenames for controllers must be in plural an without underscores, so your controller file should be named EmployeesController.php.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜