0

Doctrine 1.2.4, PHP 5.3.3
tables profile, stream, event

fk:event -> profile many-to-one
fk:event -> stream many-to-one

Stream

$this->hasMany('modelEvent as Events', array(
            'local' => 'id',
            'foreign' => 'stream_id'
));

Profile

$this->hasMany('modelEvent as Events', array(
            'local' => 'id',
            'foreign' => 'profile_id'
));

Event

 $this->hasOne('modelProfile', array(
                 'local' => 'profile_id',
                 'foreign' => 'id'
 ));

 $this->hasOne('modelStream', array(
                'local' => 'stream_id',
                'foreign' => 'id'
 ));

Relations dont work :(

<?php
    $event = new modelEvent();
    $event -> merge ($data_event);
    $event -> modelProfile -> merge($data_profile);
    $event -> modelStream -> merge($data_stream);
    $event -> save();
?>
j0k
  • 22,600
  • 28
  • 79
  • 90

1 Answers1

0

You need to use the setRelation() method to properly add relation data into a model.

For Example:

$profile = new modelProfile();
$profile->fromArray($arrayOfData); //you can optionally populate the new model with an array of values.  Values with keys that don't exist in the model will be ignored.

$event = new modelEvent();
$event->setRelation('modelProfile', $profile);
$event->save();
Slickrick12
  • 897
  • 1
  • 7
  • 21