trochę ostatnio szaleje z postami na tym forum za co chyba powinienem przeprosić. Potrzebuje jednak waszej pomocy bo nie jestem wstanie przebrnąć przez temat samodzielnie.
Projektujemy w małym zespole serwis internetowy. "Mamy" bazę, skonfigurowane symfony, stronka już zaczyna działać ale nie jest tak jakbyśmy sobie to wyobrażali. Założyliśmy sobie że kasowanie zbędnych rekordów będzie się odbywało za pośrednictwem kluczy obcych albo trigerów ( z naciskiem na te pierwsze ).
Przykładowa tabela przedstawiająca komentarze do profilu użytkownika:
AjCommentsUserprofile: connection: doctrine tableName: aj_comments_userprofile columns: id: type: integer(4) fixed: false unsigned: false primary: true autoincrement: true cu_user_id: type: integer(4) fixed: false unsigned: false primary: true autoincrement: false parent: type: integer(4) fixed: false unsigned: false primary: false notnull: false autoincrement: false content: type: string() fixed: false unsigned: false primary: false notnull: true autoincrement: false user_id: type: integer(4) fixed: false unsigned: false primary: false notnull: true autoincrement: false thumb_up: type: integer(4) fixed: false unsigned: false primary: false default: '0' notnull: false autoincrement: false thumb_down: type: integer(4) fixed: false unsigned: false primary: false default: '0' notnull: false autoincrement: false thread_id: type: integer(4) fixed: false unsigned: false primary: false notnull: true autoincrement: false created_at: type: timestamp(25) fixed: false unsigned: false primary: false notnull: true autoincrement: false updated_at: type: timestamp(25) fixed: false unsigned: false primary: false notnull: true autoincrement: false
Pytania:
- istnieje możliwość nie definiowania pola ID, jeżeli w innej tabeli jest klucz wskazujący na to pole?
- w momencie kiedy tabela zawiera 2 klucze PRIMARY to taki kod:
$form->save()->getId();
zwraca NULL. Jak w takim razie powinna być zbudowana baza żeby rekordy kasowały się CASCADE i jednocześnie działał nam model.