首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >actAs和关系在理论上意味着什么?

actAs和关系在理论上意味着什么?
EN

Stack Overflow用户
提问于 2010-02-18 12:45:38
回答 1查看 1.8K关注 0票数 1

我完全不理解下面的schema.yml:

代码语言:javascript
复制
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 }

以及如何正确定义它?

EN

回答 1

Stack Overflow用户

发布于 2010-02-18 16:15:16

又短又甜:

Behaviors ('actAs'),顾名思义,是定义模型行为(sp -对不起,British;-)的一种方法。我想说最常用的是"Timestampable“(它将已创建和更新的字段添加到您的表中并自动更新这些字段)和"SoftDelete”(它添加了一个deleted_at列,如果记录被“删除”而不是实际删除)。

这里有更多信息- 2/en/行为

Relations -与其他模型相关的模型。一篇博客文章可能会有很多评论--这篇文章和评论之间有一对多的关系。在上面的Jobeet示例中,作业属于类别。

再说一遍,这里有更多的信息- 2/en/定义-模型#关系

但是,正如上面@Marko所评论的,从文档开始:-) Symfony文档中的页面 (您已经从它获得了模式)有一张图片来解释表之间的关系.:-)

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/2288645

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档