Krzysztof Biernacki

Krzysztof Biernacki programista PHP

Temat: [sf1.4]Modul Test - problem z utworzeniem relacji

Mam problem z utworzeniem schematu i poprawnych relacji pomiedzy tabelami dla modulu Testy w swoim projekcie.
Z grubsza zalozenia sa takie, ze jeden test moze zawierac nieskonczenie wiele pytan i odpowiedzi.

Moj plik schema.yml przedstawia sie na chwile obecna nastepujaco:

ModTest:
actAs: [Timestampable]
columns:
id: { type: integer(4), primary: true, notnull: true, autoincrement: true }
slug: { type: string(255), unique: true }
title: { type: string(255), notnull: true }
keywords: { type: string(255) }
description: { type: clob(65535) }
text: { type: clob(65535) }
is_archive: { type: enum, values: ['false', 'true'], default: 'false', notnull: true }
is_active: { type: enum, values: ['false', 'true'], default: 'false', notnull: true }
publication_from: { type: timestamp }
publication_to: { type: timestamp }
relations:
module:
class: Module
local: id
foreign: id
foreignAlias: modTest
foreignType: one
indexes:
fk_ModTest_Module1:
fields: [id]

Answer:
actAs: [Timestampable]
columns:
id: { type: integer(4), primary: true, notnull: true, autoincrement: true }
test_id: { type: integer(4), notnull: true }
name: { type: string(255), notnull: true }
hits: { type: integer(4), default: 0 }
ord: { type: integer(4), notnull: true, default: 0 }
is_active: { type: enum, values: ['false', 'true'], default: 'true', notnull: true }
relations:
modTest:
local: test_id
class: ModTest
foreignType: many
foreignAlias: answers
onDelete: CASCADE
indexes:
fk_Answer_ModTest:
fields: [test_id]


Nie wiem w jaki sposob zrobic polaczenie pomiedzy tabela Answer (przechowujaca odpowiedzi na pytania) a tabela Query (w niej docelowo beda sie znajdowac pytania z testu). Ktos mi pomoze?
Krzysztof Bujok

Krzysztof Bujok PHP / Symfony2
Developer

Temat: [sf1.4]Modul Test - problem z utworzeniem relacji

Jeśli dane pytanie (Query) będzie przypisane do testu, wtedy Answer łączysz tylko do Query, które dalej łączy do ModTest. Answer nie musisz łączyć bezpośrednio do ModTest.
Inna sprawa się ma, gdy pomiędzy Query i ModTest masz relację Many-To-Many, wtedy Answer musisz podłączyć do obu tabel.

Następna dyskusja:

[sf 1.4] sfThumbnailPlugin ...




Wyślij zaproszenie do