0
votes

In my application (developed with Symfony 1.4 and Doctrine) I'm trying to get all users based on idempresa of the user logged in. idempresa is in a sf_guard_user_profiletable and this is the schema for that:

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

I'm trying with this query:

Doctrine_Core::getTable('sfGuardUser')
   ->createQuery('u')
   ->leftJoin('u.Profile p')
   ->where('idempresa = ?', $id_empresa)
   ->execute();

But get this error:

Unknown relation alias Profile

What is wrong in my code?

1

1 Answers

2
votes

Your relation between the sfGuardUser and sfGuardUserProfile is not called Profile but SfGuardUserProfile. So you should use in your query builder:

 ->leftJoin('u.SfGuardUserProfile p')