English 中文(简体)
在cakeHP中找不到控制器
原标题:Controller not found in cakePHP
  • 时间:2011-02-14 12:47:05
  •  标签:
  • cakephp

我在employee_controller.php文件中有一个控制器类EmployeeController,在employee.php中有一一个模型类Employer,数据库表是employees,所有的函数都在工作(比如findall()和read()工作得很好),但我有一个add函数,它是这样的

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

当我试图保存时,将显示一个错误EmployeesController not found,并显示以下代码

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

我解决不了这个问题,请帮我解决这个问题

问题回答

该文件应被称为employees_controller.php,而不是employee_controller.php。

所有控制器文件都以复数形式命名。

您还可以在http://cakeapp.com

我不知道这个问题是否仍然重要,但cakepp约定说控制器的文件名必须是复数,不带下划线,所以你的控制器文件应该命名为EmployeesController.php





相关问题
PHP Framework: Ebay Like Site

I am going to be builiding a site like ebay - with all the features of ebay. Please note my payment method is limited to paypal. What would be the best PHP framework to use to build this quickly, ...

specifying date format when using $form->inputs() in CakePHP

I am wondering if there is a way to specify the date format in the forms created using CakePHP s $form->inputs(); Please note that this is not the individual $form->input() but instead $form->inputs() ...

Using DISTINCT in a CakePHP find function

I am writing a CakePHP 1.2 app. I have a list of people that I want the user to be able to filter on different fields. For each filterable field, I have a drop down list. Choose the filter ...

Assistance with CakePHP model relationships

How would I represent the following in a CakePHP model? Product ======= product_id .... Cart ==== cart_id .... Carts_Products ============== cart_id product_id quantity

Prevent controller from trying to autoload model

I am a beginning Cake user and trying to do some work on an already existing application. Running into a problem when I create a new controller. I have created StoreController and when I try to call ...

热门标签