开发者

YML - Fixitures ID problems in Symfony 1.4.12

I have the follwing fixiture file:

Category:
   webDev:
      name: Development Web
   webDesign:
      name: Web Desing
   A开发者_JAVA技巧utres:
      name: Autres

Post:
   Post1:
      Category: webDev
      title: Ceci est un Test 1
      content: TEST
   Post2:
      Category: webDesign
      title: Ceci est un Test 2
      content: TEST
   Post3:
      Category: Autres
      title: Ceci est un Test 3
      content: TEST

The problem is that webDev is not recognized and the id is not automatically seted.

I don't want to use like that:

 Post1:
      category_id: 1
      title: Ceci est un Test 1
      content: TEST

But I want to use the name of the webDev, webDesign or Autres categories names. Is working and I have no error when I run:

./symfony doctrine:build --all --no-confirmation --and-load 

However, when I look in MySQL database instead of the category id I get NULL. Why? Where is the error?

Here is my schema.yml

Category:
 tableName: categories
 columns:
  name: string(100)

Post:
 tableName: posts
 actAs:
  Timestampable: ~
  Sluggable:
   fields: [title]
 columns:
  category_id: integer
  title: string(100)
  content: text
 relations:
  Category:
   type: one
   foreignType: many
   local: id
   foreign: id


According to your schema, the foreign key will bet set to post.id instead of post.category_id.

try local: category_id instead of local: id

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜