Bonjour,
je développe un site sous symfony 1.4 avec l'ORM doctrine.
J'aimerai mettre en place un système de catégorie sur plusieurs niveau, chaque catégorie pouvant bien sûr comprendre plusieurs articles.

J'ai réussi à faire ce que je voulais jusqu'à présent mais je voudrai rajouté un champ "position" supplémentaire à la table qui relie les articles aux catégories.

Dans le schema.yml aucun problème par contre je n'ai aucune idée de ce que je dois ajouter dans mon fichiers yml qui ajoute les données initiales.

Voici le fichier schema.yml
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# config/doctrine/schema.yml
Article:
  tableName: article
  columns:
    titre: { type: string(255), notnull: true }
    url:   { type: string(255), notnull: true, unique: true }
    meta_desc: { type: string(255)}
    intro: { type: clob, notnull: true }
    texte: { type: clob, notnull: true }
    etat:  { type: integer(1), notnull: true}
  relations:
    Categories:
      class:          Categorie
      refClass:       CategorieArticle
      foreignAlias:   Articles
 
Categorie:
  tableName: categorie
  columns:
    nom:   { type: string(255), notnull: true }
    url:   { type: string(255), notnull: true, unique: true }
  relations:
    CategoriesMeres:
      class:          Categorie
      refClass:       CategorieCategorie
      foreignAlias:   Categories
      local: categorie_id
      foreign: categorie_mere_id
 
CategorieArticle:
  tableName: categorie_article
  columns:
    categorie_id:  { type: integer, primary: true, notnull: true }
    article_id:   { type: integer, primary: true, notnull: true }
    position:     {type: integer, notnull: true }
  relations:
    Categorie:  { onDelete: CASCADE, local: categorie_id, foreign: id }
    Article: { onDelete: CASCADE, local: article_id, foreign: id }
 
CategorieCategorie:
  tableName: categorie_categorie
  columns:
    categorie_id:  { type: integer, primary: true, notnull: true }
    categorie_mere_id:   { type: integer, primary: true, notnull: true }
    position:     {type: integer, notnull: true }
Et mon fichier fixtures.yml
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
categorie:
  jurisprudence:        
    nom: Jurisprudence
    url: jurisprudence
  victimesIndemnisation:
    nom: Victimes et indemnisation
    url: victimes_et_indemnisation
  victimesAccidents:        
    nom: Victimes d'accidents
    url: victimes-d-accidents
    CategoriesMeres: [victimesIndemnisation,jurisprudence]
 
article:
    article1:
        titre: Embouteillage
        texte: mon texte ici !
        url: embouteillage
        etat: 1
        meta_desc: Des embouteillage à Bordeaux
        Categories: [victimesIndemnisation,victimesAccidents]