获取具有关系的两列
我和 Jobeet 一起学习 Symfony 和 Doctrine。我想添加一些修改。 默认是: http://www.symfony-project.org/jobeet/1_4/Doctrine /en/03
JobeetCategory:
actAs: { Timestampable: ~ }
columns:
name: { type: string(255), notnull: true, unique: true }
JobeetJob:
actAs: { Timestampable: ~ }
columns:
category_id: { type: integer, notnull: true }
(...)
relations:
JobeetCategory: { onDelete: CASCADE, local: category_id, foreign: id, foreignAlias: JobeetJobs }
如果我进入表单(创建新的)我有: http://www.symfony-project.org/images/jobeet /1_4/03/job.png
类别 id - 选择列表
//BaseJobeetJobForm.class.php :
'category_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('JobeetCategory'), 'add_empty' => false)),
//sfFormDoctrine.class.php :
protected function getRelatedModelName($alias)
{
$table = Doctrine_Core::getTable($this->getModelName());
if (!$table->hasRelation($alias))
{
throw new InvalidArgumentException(sprintf('The "%s" model has to "%s" relation.', $this->getModelName(), $alias));
}
$relation = $table->getRelation($alias);
return $relation['class'];
}
我怎样才能做类似的事情:
JobeetCategory:
actAs: { Timestampable: ~ }
columns:
name: { type: string(255), notnull: true, unique: true }
nametwo: { type: string(255), notnull: true, unique: true }
JobeetJob:
actAs: { Timestampable: ~ }
columns:
category_id: { type: integer, notnull: true }
nametwo_id: { type: integer, notnull: true }
(...)
relations:
JobeetCategory: { onDelete: CASCADE, local: category_id, foreign: id, foreignAlias: JobeetJobs }
JobeetCategory: { onDelete: CASCADE, local: nametwo_id, foreign: id, foreignAlias: JobeetJobsTwo }
我怎样才能以“nametwo”形式显示?我将列出两个选项(category_id(已经)和 nametwo_id:)
i learn Symfony and Doctrine with Jobeet. I would like add aeveral modifications.
default is:
http://www.symfony-project.org/jobeet/1_4/Doctrine/en/03
JobeetCategory:
actAs: { Timestampable: ~ }
columns:
name: { type: string(255), notnull: true, unique: true }
JobeetJob:
actAs: { Timestampable: ~ }
columns:
category_id: { type: integer, notnull: true }
(...)
relations:
JobeetCategory: { onDelete: CASCADE, local: category_id, foreign: id, foreignAlias: JobeetJobs }
and if i go to form (create new) i have:
http://www.symfony-project.org/images/jobeet/1_4/03/job.png
Category id - choice list
//BaseJobeetJobForm.class.php :
'category_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('JobeetCategory'), 'add_empty' => false)),
//sfFormDoctrine.class.php :
protected function getRelatedModelName($alias)
{
$table = Doctrine_Core::getTable($this->getModelName());
if (!$table->hasRelation($alias))
{
throw new InvalidArgumentException(sprintf('The "%s" model has to "%s" relation.', $this->getModelName(), $alias));
}
$relation = $table->getRelation($alias);
return $relation['class'];
}
how can I do something like:
JobeetCategory:
actAs: { Timestampable: ~ }
columns:
name: { type: string(255), notnull: true, unique: true }
nametwo: { type: string(255), notnull: true, unique: true }
JobeetJob:
actAs: { Timestampable: ~ }
columns:
category_id: { type: integer, notnull: true }
nametwo_id: { type: integer, notnull: true }
(...)
relations:
JobeetCategory: { onDelete: CASCADE, local: category_id, foreign: id, foreignAlias: JobeetJobs }
JobeetCategory: { onDelete: CASCADE, local: nametwo_id, foreign: id, foreignAlias: JobeetJobsTwo }
how can i show in form "nametwo"? i will two list choices (category_id (already) and nametwo_id: )
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您想在 jobeetjob 和 jobeetcategory 之间建立两个不同的关系。
您必须清楚地命名该关系,如下所示:
You want to setup two distinct relation between jobeetjob and jobeetcategory.
You have to name distinctly the relation, like this :