开发者

"SQLSTATE[23000]: Integrity constraint violation" in Doctrine

i do get an Integrity constraint violation for Doctrine though i really can't see why.

Schema.yml

User:
  columns:
    id:
      type: integer
      primary: true
      autoincrement: true
    username:
      type: varchar(64)
      notnull: true
    email:
      type: varchar(128)
      notnull: true
    password:
      type: varchar(128)
      notnull: true
  relations:
    Websites:
      class: Website
      local: id
      foreign: owner
      type: many
      foreignType: one
      onDelete: CASCADE

Website:
  col开发者_Python百科umns:
    id:
      type: integer
      primary: true
      autoincrement: true
    active:
      type: bool
    owner:
      type: integer
      notnull: true
    plz:
      type: integer
      notnull: true
    longitude:
      type: double(10,6)
      notnull: true
    latitude:
      type: double(10,6)
      notnull: true
  relations:
    Owner:
      type: one
      foreignType: many
      class: User
      local: owner
      foreign: id

And here's my data Fixtures (data.yml)

Model_User:
  User_1:
    username: as
    email: as****.com
    password: *****

Model_Website:
  Website_1:
    active: true
    plz: 34222
    latitude: 13.12
    longitude: 3.56
    Owner: User_1


Okay, i found the Problem. The Reason for this Error was that i already altered the Model_User and added an Attribute "owner" and then Doctrine tried to add the already existing attribute to the Model.

Long Story short: Do not define variables in your Models that do exist in your yaml schema as well!

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜