0

我正在尝试将一个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

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

4

1 回答 1

1

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

 relations:
    SfGuardUser:
      local: user_id
      foreign: id
      type: one
      foreignAlias: SfGuardUserProfile
于 2013-06-07T19:41:40.553 回答