Make the new hasOne stuff work with identifiers
This commit is contained in:
parent
17787aa173
commit
a903c927c4
@ -883,7 +883,11 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
|
|||||||
throw new Doctrine_Record_Exception("Couldn't call Doctrine::set(), second argument should be an instance of Doctrine_Record or Doctrine_Null when setting one-to-one references.");
|
throw new Doctrine_Record_Exception("Couldn't call Doctrine::set(), second argument should be an instance of Doctrine_Record or Doctrine_Null when setting one-to-one references.");
|
||||||
}
|
}
|
||||||
if ($rel instanceof Doctrine_Relation_LocalKey) {
|
if ($rel instanceof Doctrine_Relation_LocalKey) {
|
||||||
$this->set($rel->getLocal(), $value->rawGet($rel->getForeign()), false);
|
$foreign = $rel->getForeign();
|
||||||
|
if (!empty($foreign) && $foreign != $value->getTable()->getIdentifier())
|
||||||
|
$this->set($rel->getLocal(), $value->rawGet($foreign), false);
|
||||||
|
else
|
||||||
|
$this->set($rel->getLocal(), $value, false);
|
||||||
} else {
|
} else {
|
||||||
$value->set($rel->getForeign(), $this, false);
|
$value->set($rel->getForeign(), $this, false);
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ class Doctrine_Relation_LocalKey extends Doctrine_Relation
|
|||||||
->query($dql, array($id))
|
->query($dql, array($id))
|
||||||
->getFirst();
|
->getFirst();
|
||||||
|
|
||||||
if ( ! $related) {
|
if ( ! $related || empty($related)) {
|
||||||
$related = $this->getTable()->create();
|
$related = $this->getTable()->create();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user