开发者

What is the Best way to use an ORM on an existing project

We have a huge project with multiple databases and tables. Would you recomend doctrine or similar? Hat ould be your approach in creating models for some objects? For example our users object is composed by 3 tables with 1 to N relation开发者_如何学Cs between them such. Dba.userlogin Dbb.userprofile Dbb.lient.userid Etc

Any suggestion or tip is welcomed.

We are using php. Thanks


The main reason for using an ORM is speed of development, and, to a lesser extent to force you into best OO practice.

Once you actually have a system the speed of development doesn't really matter any more. If you have seriously deviated from the standard OO patterns when writing the system it will be a real pain to coerce your design to use an ORM , and, if you did follow best practice anyway it will be easier to convert to an ORM -- but what are you really gaining.

You should evaluate the effort and risks involved in such a major re-factoring versus the benefits expected.

You could look at something iBatisy like SQLMap which would let you leave most of your existing code as is but allow you to take an ORM approach for re-factored and new code.


If you don't want to change the schema, then use the straightforward mapping of one table to each object. There are schema-to-model translators for Doctrine. You can mark the relationship between users, profiles and userids in the model and Doctrine will provide the appropriate linkages ($user->getProfile, etc).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜