我完全不理解下面的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 }以及如何正确定义它?
发布于 2010-02-18 16:15:16
又短又甜:
Behaviors ('actAs'),顾名思义,是定义模型行为(sp -对不起,British;-)的一种方法。我想说最常用的是"Timestampable“(它将已创建和更新的字段添加到您的表中并自动更新这些字段)和"SoftDelete”(它添加了一个deleted_at列,如果记录被“删除”而不是实际删除)。
这里有更多信息- 2/en/行为
Relations -与其他模型相关的模型。一篇博客文章可能会有很多评论--这篇文章和评论之间有一对多的关系。在上面的Jobeet示例中,作业属于类别。
再说一遍,这里有更多的信息- 2/en/定义-模型#关系
但是,正如上面@Marko所评论的,从文档开始:-) Symfony文档中的页面 (您已经从它获得了模式)有一张图片来解释表之间的关系.:-)
https://stackoverflow.com/questions/2288645
复制相似问题