将配置文件字段附加到Symfony和sfDoctrineGuard插件中创建的用户

时间:2013-06-07 15:41:33

标签: symfony-1.4 sfdoctrineguard

我正在尝试将idempresa字段附加到sfDoctrineGuardPlugin但无法使其正常工作。这是这些表的schema.yml(只是相关表):

SdrivingEmpresa:
  connection: doctrine
  tableName: sdriving_empresa
  columns:
    idempresa:
      type: integer(4)
      fixed: false
      unsigned: true
      primary: true
      autoincrement: true
    idlogotipo:
      type: integer(4)
      fixed: false
      unsigned: true
      primary: true
      autoincrement: false
    nombre_empresa:
      type: string(250)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    ruta_emp:
      type: string(45)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
  relations:
    SdrivingLogotipo:
      local: idlogotipo
      foreign: idlogotipo
      type: one
    SdrivingEmisor:
      local: idempresa
      foreign: idempresa
      type: many
    SdrivingMaquina:
      local: idempresa
      foreign: idempresa
      type: many
    SdrivingOperador:
      local: idempresa
      foreign: idempresa
      type: many
    SdrivingTurno:
      local: idempresa
      foreign: idempresa
      type: many
    SfGuardUserProfile:
      local: idempresa
      foreign: idempresa
      type: many

SfGuardUserProfile:
  connection: doctrine
  tableName: sf_guard_user_profile
  columns:
    user_id:
      type: integer(8)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    idempresa:
      type: integer(4)
      fixed: false
      unsigned: true
      primary: true
      autoincrement: false
  relations:
    SfGuardUser:
      local: user_id
      foreign: id
      type: one
    SdrivingEmpresa:
      local: idempresa
      foreign: idempresa
      type: one

如果我这样做:

# php symfony doctrine:dql "FROM sfGuardUser u, u.SfGuardUserProfile p"
>> doctrine  executing dql query

我收到此错误:

>> DQL: FROM sfGuardUser u, u.SfGuardUserProfile p
>> Unknown relation alias SfGuardUserProfile

我做错了什么?我的错误在哪里?

1 个答案:

答案 0 :(得分:1)

尝试在SfGuardUserProfile实体中为sfGuardUser添加foreignAlias,例如:

 relations:
    SfGuardUser:
      local: user_id
      foreign: id
      type: one
      foreignAlias: SfGuardUserProfile