Sunday, 15 April 2012

What is the best way to use old database schema in new CakePHP application? -


Currently I have a PHP application that runs without any framework.

For several reasons I rebuild that app by using the CakePHP framework. However, this app has an old database plan that does not follow cake practices (it's not even in English).

I want to slice this application and recreate it and the older parts which have not yet migrated, so I can not make any real schema changes.

Is it possible to make some types of proxy routes between the new plan and the old plan? To do this, it is not possible to work in a cake as I want (for example, the field 'user_name' in the model "user"), but the old database scheme on the background (like 'name' in the 'name' table) Use.

Model

Model kppp 2.x Proxy is not the behavior you want.

Still, you can create your own app by following some of the most important CakePHp conventions by adding some model settings:

  • You can specify the table used by the < Code> id (), then each model with $ useTable property
  • you can specify primaryKey
  • You can use a custom foreignKey to set the relationship between the two models (check this answer In which there is a good explanation)

It should get you started and left the table field name changes later.

Official document and


No comments:

Post a Comment