Create models with Already created database NO CONVENTIONS


#1

Hello everyone, i just started in cake, so i have a database from another app and i want to use it with cake, i tried to create the model or controllers by the BAKE command, but i cant because my DB isnt with the convention and i cant change the DB, what can i do??


#2

You have to do it manually. See Help command cake bake thread


#3

I would suggest that you should change table names and entity names according to CakePHP conventions. It will save you from tons of trouble.


#4

Oh, thank you, just one thing, i was looking for an example of a model, can post an example of a model?


#5

Perhaps something like this :
public function initialize(array $config)
{
parent::initialize($config);

    $this->table('name_of_the_table');
    $this->displayField('name_of_display_field');
    $this->primaryKey('name_of_primary_key');

}