This commit is contained in:
parent
134c944bc7
commit
60136a4b0a
@ -142,26 +142,24 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
|
|||||||
{
|
{
|
||||||
$saveLater = array();
|
$saveLater = array();
|
||||||
foreach ($record->getReferences() as $k => $v) {
|
foreach ($record->getReferences() as $k => $v) {
|
||||||
$fk = $record->getTable()->getRelation($k);
|
$rel = $record->getTable()->getRelation($k);
|
||||||
if ($fk instanceof Doctrine_Relation_ForeignKey ||
|
|
||||||
$fk instanceof Doctrine_Relation_LocalKey) {
|
|
||||||
$local = $fk->getLocal();
|
|
||||||
$foreign = $fk->getForeign();
|
|
||||||
|
|
||||||
if ($record->getTable()->hasPrimaryKey($fk->getLocal())) {
|
if ($rel instanceof Doctrine_Relation_ForeignKey ||
|
||||||
|
$rel instanceof Doctrine_Relation_LocalKey) {
|
||||||
|
$local = $rel->getLocal();
|
||||||
|
$foreign = $rel->getForeign();
|
||||||
|
|
||||||
|
if ($record->getTable()->hasPrimaryKey($rel->getLocal())) {
|
||||||
if ( ! $record->exists()) {
|
if ( ! $record->exists()) {
|
||||||
$saveLater[$k] = $fk;
|
$saveLater[$k] = $rel;
|
||||||
} else {
|
} else {
|
||||||
$v->save($this->conn);
|
$v->save($this->conn);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// ONE-TO-ONE relationship
|
// ONE-TO-ONE relationship
|
||||||
$obj = $record->get($fk->getAlias());
|
$obj = $record->get($rel->getAlias());
|
||||||
|
|
||||||
if ($obj->exists()) {
|
|
||||||
$obj->save($this->conn);
|
$obj->save($this->conn);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user