Nowe posty

xx Dystrybucja pod HP Omen (6)
Wczoraj o 23:30:08
xx [Poradnik] Wyszukiwanie Sterowników (2)
Wczoraj o 21:08:23
lamp Problem z Linux Lite po instalacji (0)
Wczoraj o 19:50:30
xx Ile pingwinów? (1)
Wczoraj o 08:59:24
xx konfiguracja pale moon (0)
2024-03-24, 21:53:42
xx Plasma 6 w Neonie ssie trochę mniej ... (10)
2024-03-23, 02:38:11
xx problem z instalacja sterowników do karty sieciowej (3)
2024-03-18, 18:10:16
xx Plik abc.001 (1)
2024-03-17, 17:48:27
xx Zlecę dopracowanie programu w MatLab (0)
2024-03-13, 15:28:40
xx Linux Mint 21.3 XFCE brak dźwieku po paru minutach (karta muzyczna zintegrowana) (5)
2024-03-12, 23:07:01

Autor Wątek: Symphony błąd przy generowaniu sql  (Przeczytany 3996 razy)

  • Gość
Symphony błąd przy generowaniu sql
« dnia: 2010-03-24, 08:01:51 »
Przy próbie generowania wyświetla mnie się błąd:

Cytuj
tomasz@tomasz-laptop:~/project/symfony$ ./symfony doctrine:build --sql
>> doctrine  generating model classes
>> file+     /tmp/doctrine_schema_92534.yml

                                                                       
  Invalid schema element named "articles_category" at path "doctrine"
Mój schema to:

# config/doctrine/schema.yml

doctrine:
   articles_category:
     actAs: { Timestampable: ~ }
     columns:
      id:            ~
      name:          { type: VARCHAR (255) , index: required , index: required }
      description:   { type: varchar(255) }
      parent:        { type: integer }
      visible:       { type: boolean }
      creation_date: { type: timestamp }
      moderator:     { type: integer }
      group:         { type: integer , index: required }

   articles_entries:
     actAs: { Timestampable: ~ }
     columns:
      id:            ~
      description:   { type: string(255) , index: required , index: unique }
      content:       { type: string (65535) }
      category:      { type: integer }
      visible:       { type: boolean }
      creation_date: { type: timestamp }
      author:        { type: integer }
     
   users:
     actAs: { Timestampable: ~ }
     columns:
      id:            ~
      login:         { type: varchar (32) }
      password:      { type: varchar (32) }
      name:          { type: varchar (255) }
      last_name:     { type: varchar (255) }
      creation_date  { type: timestamp }
      blocked:       { type: boolean }
Co jest nie tak z tym category

ZipoKing

  • Gość
Symphony błąd przy generowaniu sql
« Odpowiedź #1 dnia: 2010-03-24, 08:55:50 »
Prawie poprawna forma:
Kod: YAML [Zaznacz]

ArticlesCategory:
  actAs: { Timestampable: ~ }
  columns:    
    id:            ~
    name:          { type: string(255) , notnull: true }
    description:   { type: string(255) }
    parent:        { type: integer }
    visible:       { type: boolean }
    creation_date: { type: timestamp }
    moderator:     { type: integer }
    group:         { type: integer , notnull: true }

ArticlesEntries:
  actAs: { Timestampable: ~ }
  columns:
    id:            ~
    description:   { type: string(255) , notnull: true, unique: true }
    content:       { type: text }
    category:      { type: integer }
    visible:       { type: boolean }
    creation_date: { type: timestamp }
    author:        { type: integer }
     
Users:
  actAs: { Timestampable: ~ }
  columns:
    id:            ~
    login:         { type: string(32) }
    password:      { type: string(32) }
    name:          { type: string(255) }
    last_name:     { type: string(255) }
    creation_date  { type: timestamp }
    blocked:       { type: boolean }

1. (to nie jest błąd, ale...) pamiętaj o tzw. Camel Case (jak kalsę nazwiesz ArticlesEntries to Doctrine stworzy dla niej tabelę articles_entries etc.)
2. Nie index: unique, tylko unique: true
3. Nie index:required, tylko notnull: true
4. Pamiętaj że Doctrine przy generowaniu zapytań dla MySQL nie escapuje nazw kolumn. Ty używasz kolumny "group" w tabeli articles_categories, a "group" jest zarezerwowanym słowem kluczowym SQL - w wyniku tego zapytanie ci się nie wykona, ponieważ MySQL zgłosi błąd składni. Rozwiązanie: albo zmień nazwę kolumny albo zmodyfikuj kod Doctrine tak, aby zaczął nazwy kolumn escapować (gdzieś to kiedyś robiłem, więc jakby co mogę ci podesłać snippeta :))
5. Top level ścieżki to nazwy kolumn/klas a nie "doctrine"