Hi, I have the following schema:

Artist - ArtistSession - Session

Artist:
  columns:
    id:
      primary: true
      type: integer
      notnull: true
      autoincrement: true
<snip>...</snip>
  relations:
    Sessions:
      class: Session
      refClass: ArtistSession
      local: artist_id
      foreign: session_id


ArtistSession:
  columns:
    artist_id:
      primary: true
      type: integer
      notnull: true
    session_id:
      primary: true
      type: integer
      notnull: true
  relations:
    Artist:
      local: artist_id
      foreign: id
    Session:
      local: session_id
      foreign: id


Session:
  columns:
    id:
      primary: true
      type: integer
      notnull: true
<snip>...</snip>


I assumed I could do something like

$sessions = Doctrine::getTable('Session')->findByFoo('bar');
$artist->setSessions($sessions);
$artist->save();

which would automatically create the ArtistSession relation on the
save, but it doesn't.

What you actually have to do is
$artist->getSessions()->merge($sessions);

Which will then successfully create the join records. Why is this? Is
there something merge() does that set<RelationAlias>() doesn't?



-- 
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