开发者

Save method override and exceptions management

Currently, I am developing an application which domain model should prevent objects duplication according the equality or not of some object fields.

So, I am thinking to handle this comparison on the save method of the class: if some existing object has some properties equal to the object to be saved, the save should be prevented.

I am thinking to deal this situation with an Exceptions, which would be thrown and catched in the action, in order to present a message to the user, if necessary开发者_如何学运维. Unfortunately, my knowledge about Exceptions is not quite good and more: would be this solution the most adequate?

The ORM which I am using is Doctrine.


Why don't you create an unique index on multiple columns in your schema: This is an example taken from Doctrine's manual:

MultipleIndexTest:
  columns:
    name: string
    code: string
    age: integer
  indexes:
    myindex:
      fields:
        name:
          sorting: ASC
          length: 10
        code: -
      type: unique
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜