CakePHP模型不使用指定的表名

时间:2014-03-06 21:05:19

标签: php postgresql cakephp

我只是想指定一个模型的表名,但它不起作用! 这是我的AccountModel.php文件

App::uses('AppModel', 'Model');

class Account extends AppModel
{

    public $name = 'Account';
    public $useTable = 'account';
    public $table = 'account';

    public $primaryKey = 'id_account';


}

但我不知道为什么它给了我这个结果

Error: Table accounts for model Account was not found in datasource default.

Notice: If you want to customize this error message, create app/View/Errors/missing_table.ctp
Stack Trace

    CORE/Cake/Model/Model.php line 3498 → Model->setSource(string)
CORE/Cake/Model/Model.php line 1355 → Model->getDataSource()
    CORE/Cake/View/Helper/FormHelper.php line 207 → Model->schema()
    CORE/Cake/View/Helper/FormHelper.php line 459 → FormHelper->_introspectModel(string, string)
    APP/View/Account/login.ctp line 4 → FormHelper->create(null, array)
    CORE/Cake/View/View.php line 935 → include(string)
    CORE/Cake/View/View.php line 897 → View->_evaluate(string, array)
    CORE/Cake/View/View.php line 466 → View->_render(string)
CORE/Cake/Controller/Controller.php line 952 → View->render(null, null)
    CORE/Cake/Routing/Dispatcher.php line 192 → Controller->render()
    CORE/Cake/Routing/Dispatcher.php line 160 → Dispatcher->_invoke(AccountController, CakeRequest, CakeResponse)
    APP/webroot/index.php line 108 → Dispatcher->dispatch(CakeRequest, CakeResponse)

有人对我的问题有所了解吗?

1 个答案:

答案 0 :(得分:1)

您的模型文件名必须是Account.php而不是AccountModel.php