Commit 6c0b5fd3 authored by nightfreak's avatar nightfreak

added the fix for ticket #398. also fixed the missing $coll->setReference() in...

added the fix for ticket #398. also fixed the missing $coll->setReference() in Doctrine_Relation_Association::fetchRelatedFor()
parent b243286b
......@@ -57,16 +57,11 @@ class Doctrine_Relation_Association extends Doctrine_Relation
$component = $this->definition['refTable']->getComponentName();
switch ($context) {
case "record":
$sub = 'SQL:SELECT ' . $this->definition['foreign'].
' FROM ' . $this->definition['refTable']->getTableName().
' WHERE ' . $this->definition['local'] .
' IN (' . substr(str_repeat("?, ", $count),0,-2) .
')';
$sub = substr(str_repeat("?, ", $count),0,-2);
$dql = 'FROM ' . $this->getTable()->getComponentName();
$dql .= '.' . $component;
$dql .= ' WHERE ' . $this->getTable()->getComponentName()
. '.' . $this->getTable()->getIdentifier() . ' IN (' . $sub . ')';
. '.' . $component . '.' . $this->definition['local'] . ' IN (' . $sub . ')';
break;
case "collection":
$sub = substr(str_repeat("?, ", $count),0,-2);
......@@ -93,6 +88,7 @@ class Doctrine_Relation_Association extends Doctrine_Relation
} else {
$coll = Doctrine_Query::create()->parseQuery($this->getRelationDql(1))->execute(array($id));
}
$coll->setReference($record, $this);
return $coll;
}
}
......@@ -67,8 +67,8 @@ class Address extends Doctrine_Record
{
public function setUp()
{
$this->hasMany('User', array('local' => 'user_id',
'foreign' => 'address_id',
$this->hasMany('User', array('local' => 'address_id',
'foreign' => 'user_id',
'refClass' => 'EntityAddress'));
}
public function setTableDefinition() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment