Jeremie
Jeremie

Reputation: 379

CakePHP model doesn't use the specified table name

I'm simply trying to specify an the table name of a model, but it doesn't work ! Here is my AccountModel.php file

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

class Account extends AppModel
{

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

    public $primaryKey = 'id_account';


}

But I don't know why it gives me this result

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)

Is anyone have an idea about my problem ?

Upvotes: 0

Views: 275

Answers (1)

arilia
arilia

Reputation: 9398

your Model file name must be Account.php and not AccountModel.php

Upvotes: 1

Related Questions