where do I go to read more about the refClass and relations on extended
schema? I have looked at the extended schema sections of some of the books
but all of the lack depth in explaining precisely this...

On Fri, Oct 22, 2010 at 6:50 PM, Stéphane <stephane.er...@gmail.com> wrote:

> Hi,
>
> You don't need refClass for 1-to-1 !
>
> Cheers,
>
> Before Printing, Think about Your Environmental Responsibility!
> Avant d'Imprimer, Pensez à Votre Responsabilitée Environnementale!
>
>
>
> On Sat, Oct 23, 2010 at 1:31 AM, Jonotron <jonot...@gmail.com> wrote:
> > I want to create a one-to-one relationship between users and
> > companies. Since I shouldn't be editing the sfDoctrineGuard schema's
> > directlyI've created a sfGuardUserProfile model:
> >
> > sfGuardUserProfile:
> >  tableName:            sf_guard_user_profile
> >  columns:
> >    user_id:            { type: integer, notnull: true }
> >    org_id:             { type: integer, notnull: true }
> >  relations:
> >    sfGuardUser:        { onDelete: CASCADE, local: user_id, foreign:
> > id, foreignAlias: Profile, foreignType: one, type: one }
> >    Company:        { onDelete: CASCADE, local: org_id, foreign: id,
> > foreignAlias: sfGuardUserProfiles }
> >
> >
> > And my Company model has a relation like this:
> >  relations:
> >    sfGuardUser:
> >      foreignAlias: Company
> >      class: sfGuardUser
> >      local: id
> >      foreign: org_id
> >      refClass: sfGuardUserProfile
> >      foreignType: one
> >
> > This appears to create all the correct models, the basesfGuardUser
> > model has:
> >
> >        $this->hasOne('Company', array(
> >             'refClass' => 'sfGuardUserProfile',
> >             'local' => 'org_id',
> >             'foreign' => 'id'));
> >
> >
> > However, when I do:
> > $sf_user->getGuardUser()->getCompany();
> >
> > it returns a collection rather than an object. The simple fix is to do
> > this:
> > $sf_user->getGuardUser()->getProfile()->getCompany();
> >
> > (and refactor it into the sfGuardUser class)
> >
> > I suspect that the refClass is what is causing this behaviour. Is this
> > intended? is there another way to create a one-to-one relationship as
> > I've described above? My solution works, but it feels wrong somehow.
> >
> > Thanks
> >
> >
> > --
> > If you want to report a vulnerability issue on symfony, please send it to
> security at symfony-project.com
> >
> > You received this message because you are subscribed to the Google
> > Groups "symfony users" group.
> > To post to this group, send email to symfony-users@googlegroups.com
> > To unsubscribe from this group, send email to
> > symfony-users+unsubscr...@googlegroups.com<symfony-users%2bunsubscr...@googlegroups.com>
> > For more options, visit this group at
> > http://groups.google.com/group/symfony-users?hl=en
> >
>
> --
> If you want to report a vulnerability issue on symfony, please send it to
> security at symfony-project.com
>
> You received this message because you are subscribed to the Google
> Groups "symfony users" group.
> To post to this group, send email to symfony-users@googlegroups.com
> To unsubscribe from this group, send email to
> symfony-users+unsubscr...@googlegroups.com<symfony-users%2bunsubscr...@googlegroups.com>
> For more options, visit this group at
> http://groups.google.com/group/symfony-users?hl=en
>

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to