2010-02-18 3 views
1

Я полностью убыточно со следующим schema.yml:Что означает действие и отношения в доктрине?

JobeetCategory: 
    actAs: { Timestampable: ~ } 
    columns: 
    name: { type: string(255), notnull: true, unique: true } 

JobeetJob: 
    actAs: { Timestampable: ~ } 
    columns: 
    category_id: { type: integer, notnull: true } 
    type:   { type: string(255) } 
    company:  { type: string(255), notnull: true } 
    logo:   { type: string(255) } 
    url:   { type: string(255) } 
    position:  { type: string(255), notnull: true } 
    location:  { type: string(255), notnull: true } 
    description: { type: string(4000), notnull: true } 
    how_to_apply: { type: string(4000), notnull: true } 
    token:  { type: string(255), notnull: true, unique: true } 
    is_public: { type: boolean, notnull: true, default: 1 } 
    is_activated: { type: boolean, notnull: true, default: 0 } 
    email:  { type: string(255), notnull: true } 
    expires_at: { type: timestamp, notnull: true } 
    relations: 
    JobeetCategory: { onDelete: CASCADE, local: category_id, foreign: id, foreignAlias: JobeetJobs } 

JobeetAffiliate: 
    actAs: { Timestampable: ~ } 
    columns: 
    url:  { type: string(255), notnull: true } 
    email:  { type: string(255), notnull: true, unique: true } 
    token:  { type: string(255), notnull: true } 
    is_active: { type: boolean, notnull: true, default: 0 } 
    relations: 
    JobeetCategories: 
     class: JobeetCategory 
     refClass: JobeetCategoryAffiliate 
     local: affiliate_id 
     foreign: category_id 
     foreignAlias: JobeetAffiliates 

JobeetCategoryAffiliate: 
    columns: 
    category_id: { type: integer, primary: true } 
    affiliate_id: { type: integer, primary: true } 
    relations: 
    JobeetCategory: { onDelete: CASCADE, local: category_id, foreign: id } 
    JobeetAffiliate: { onDelete: CASCADE, local: affiliate_id, foreign: id } 

И как правильно определить?

+3

Вы даже пробовали прочитать документацию? – Marko

ответ

4

Короткие и сладкий:

Поведение («ACTAS»), как следует из названия, способ определения поведения (зр - извините, британский ;-)) модели. Я бы сказал, что наиболее часто используемыми являются «Timestampable» (который добавляет созданные и обновленные поля в вашу таблицу и автоматически обновляет их) и «SoftDelete» (который добавляет столбец deleted_at, timestamped, если запись «удалена», а не фактически удаление записи).

Подробнее здесь - http://www.doctrine-project.org/documentation/manual/1_2/en/behaviors

Отношения - связанные модели с другими моделями. Например, сообщение в блоге, вероятно, содержит много комментариев - отношения «один ко многим» между сообщением и комментариями. В приведенном выше примере Jobeet Job принадлежит к категории.

и снова, подробнее здесь - http://www.doctrine-project.org/documentation/manual/1_2/en/defining-models#relationships

Но, как заметил выше @Marko, начните с документацией :-) The page из документации Symfony, который вы получили схему из даже имеет картину объясните отношения между таблицами ... :-)

Смежные вопросы