Php 获取具有关系的两列

Php 获取具有关系的两列,php,symfony-1.4,doctrine-1.2,Php,Symfony 1.4,Doctrine 1.2,我通过Jobeet学习符号和教义。我想添加一些修改。 默认值为: 如果我去表单(创建新的),我有: 类别id-选择列表 //BaseJobeetJobForm.class.php: 'category_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('JobeetCategory'), 'add_empty' => false)), //sffor

我通过Jobeet学习符号和教义。我想添加一些修改。 默认值为:

如果我去表单(创建新的),我有:

类别id-选择列表

//BaseJobeetJobForm.class.php:

 'category_id'  => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('JobeetCategory'), 'add_empty' => false)),
//sfformdoctor.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 } 

我如何在表格“名称二”中显示?我将列出两个选项(category_id(已存在)和nametou id:)

您想在jobeetjob和jobeetcategory之间建立两种不同的关系。
您必须清楚地命名关系,如下所示:

    JobeetJob:   
     actAs: { Timestampable: ~ }  
     columns:
       category_id:  { type: integer, notnull: true }
       nametwo_id:  { type: integer, notnull: true }  (...)   
     relations:
       JobeetCategoryOne: 
         class: JobeetCategory
         onDelete: CASCADE
         local: category_id
         foreign: id
         foreignAlias: JobeetJobs  
       JobeetCategoryTwo: 
         class: JobeetCategory
         onDelete: CASCADE
         local: nametwo_id, foreign: id,
         foreignAlias: JobeetJobsTwo 

dxb:我已经编辑了你的答案并修复了语法突出显示。对于代码示例,所有行都应该附加四个空格,以便SO高亮显示。正式确定。
    JobeetJob:   
     actAs: { Timestampable: ~ }  
     columns:
       category_id:  { type: integer, notnull: true }
       nametwo_id:  { type: integer, notnull: true }  (...)   
     relations:
       JobeetCategoryOne: 
         class: JobeetCategory
         onDelete: CASCADE
         local: category_id
         foreign: id
         foreignAlias: JobeetJobs  
       JobeetCategoryTwo: 
         class: JobeetCategory
         onDelete: CASCADE
         local: nametwo_id, foreign: id,
         foreignAlias: JobeetJobsTwo