Symfony1 无法仅获取具有相同idempresa的用户
在我的应用程序(使用Symfony 1.4和Doctrine开发)中,我试图根据登录用户的Symfony1 无法仅获取具有相同idempresa的用户,symfony1,symfony-1.4,sfdoctrineguard,Symfony1,Symfony 1.4,Sfdoctrineguard,在我的应用程序(使用Symfony 1.4和Doctrine开发)中,我试图根据登录用户的idempresa获取所有用户idempresa位于sf\u-guard\u-user\u-profile表中,这是该表的架构: SfGuardUserProfile: connection: doctrine tableName: sf_guard_user_profile columns: id: { type: integer(8), primary: true } use
idempresa
获取所有用户idempresa
位于sf\u-guard\u-user\u-profile
表中,这是该表的架构:
SfGuardUserProfile:
connection: doctrine
tableName: sf_guard_user_profile
columns:
id: { type: integer(8), primary: true }
user_id: { type: integer(8), primary: false }
idempresa: { type: integer(4), primary: false }
relations:
User:
local: user_id
class: sfGuardUser
type: one
foreignType: one
foreignAlias: SfGuardUserProfile
onDelete: CASCADE
onUpdate: CASCADE
我正在尝试此查询:
Doctrine_Core::getTable('sfGuardUser')
->createQuery('u')
->leftJoin('u.Profile p')
->where('idempresa = ?', $id_empresa)
->execute();
但是得到这个错误:
未知关系别名配置文件
我的代码有什么问题?您的
sfGuardUser
和sfGuardUserProfile
之间的关系不称为Profile
,而称为sfGuardUserProfile
。因此,您应该在查询生成器中使用:
->leftJoin('u.SfGuardUserProfile p')
我敢肯定我试过了,但没用,可能是打字错误,凌晨2点我就累了,不管怎样,凌晨2点写代码肯定很有趣,但你很容易被这样简单的错误卡住