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: Relations symfony  (Przeczytany 4961 razy)

  • Gość
Relations symfony
« dnia: 2010-12-04, 22:32:56 »
Czy ktoś mógłby objaśnić mnie co znaczą foreignAlias, refClass, Class parametry w schema.yml (pliku konfiguracyjnym symfony)... Szukałem w dokumentacji Doctrine, ale znalazłem tylko przykładowe rozwiązania i nadal nie rozumię co one znaczą.

ZipoKing

  • Gość
Relations symfony
« Odpowiedź #1 dnia: 2010-12-04, 22:46:07 »
Jak wynika z pierwszego wyniku Google'a:
- foreignAlias to atrybut pod którym widzimy daną klasę z drugiej stronę relacji
- class i refClass służą do zdefiniowania relacji wiele-do-wielu

  • Gość
Relations symfony
« Odpowiedź #2 dnia: 2010-12-05, 10:51:46 »
Byłem już na tej stronie:
Cytuj
Szukałem w dokumentacji Doctrine, ale znalazłem tylko przykładowe rozwiązania
Cytuj
The foreignType and foreignAlias options allow you to customize the opposite end of the relationship.
ForeignType and foreignAlias opcje pozwalają dostosować drugi koniec relacji... Nie do końca jasne...

a class i refClass jest w ogóle nie wyjaśnione... Class jest też nie tylko w one-to-one..., o ile wiem to tylko refClass jest w many-to-many

Tak po za tym gdzie w pliku podajemy, do której tabeli to się tyczy... Gdy mamy contact_id i tabele contact to doctrine sam się domyśli, natomiast gdy jest inaczej to jak podać i gdzie

Cytuj
Normally it would have automatically generated User has one Contact and Contact has many User. The foreignType and foreignAlias options allow you to customize the opposite end of the relationship
foreignAlias pozwala nam zamienić z contact na usermodel... Tej tabeli w ogóle nie ma.. Więc co dla tej tabeli znaczy UserModel?

Cytuj
One to Many
---
User:
  columns:
    id:
      type: integer(4)
      primary: true
      autoincrement: true
    contact_id:
      type: integer(4)
    username:
      type: string(255)
    password:
      type: string(255)

Phonenumber:
  columns:
    id:
      type: integer(4)
      primary: true
      autoincrement: true
    name:
      type: string(255)
    user_id:
      type: integer(4)
  relations:
    User:
      foreignAlias: Phonenumbers
Many to Many
---
User:
  columns:
    id:
      type: integer(4)
      autoincrement: true
      primary: true
    username:
      type: string(255)
    password:
      type: string(255)
  attributes:
    export: all
    validate: true

Group:
  tableName: group_table
  columns:
    id:
      type: integer(4)
      autoincrement: true
      primary: true
    name:
      type: string(255)
  relations:
    Users:
      foreignAlias: Groups
      class: User
      refClass: GroupUser

GroupUser:
  columns:
    group_id:
      type: integer(4)
      primary: true
    user_id:
      type: integer(4)
      primary: true
  relations:
    Group:
      foreignAlias: GroupUsers
    User:
      foreignAlias: GroupUsers
W przykładzie one-to-many jak symfony wie, że trzeba contact_id powiązać z tabelą phonenumber?