【问题标题】:Attach profile fields to created users in Symfony and sfDoctrineGuard plugin将配置文件字段附加到 Symfony 和 sfDoctrineGuard 插件中创建的用户
【发布时间】:2013-06-07 15:41:32
【问题描述】:

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

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

【问题讨论】:

    标签: symfony-1.4 sfdoctrineguard


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-02-08
      • 1970-01-01
      • 1970-01-01
      • 2011-09-28
      • 1970-01-01
      • 2021-04-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多