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 ...@@ -57,16 +57,11 @@ class Doctrine_Relation_Association extends Doctrine_Relation
$component = $this->definition['refTable']->getComponentName(); $component = $this->definition['refTable']->getComponentName();
switch ($context) { switch ($context) {
case "record": case "record":
$sub = 'SQL:SELECT ' . $this->definition['foreign']. $sub = substr(str_repeat("?, ", $count),0,-2);
' FROM ' . $this->definition['refTable']->getTableName().
' WHERE ' . $this->definition['local'] .
' IN (' . substr(str_repeat("?, ", $count),0,-2) .
')';
$dql = 'FROM ' . $this->getTable()->getComponentName(); $dql = 'FROM ' . $this->getTable()->getComponentName();
$dql .= '.' . $component; $dql .= '.' . $component;
$dql .= ' WHERE ' . $this->getTable()->getComponentName() $dql .= ' WHERE ' . $this->getTable()->getComponentName()
. '.' . $this->getTable()->getIdentifier() . ' IN (' . $sub . ')'; . '.' . $component . '.' . $this->definition['local'] . ' IN (' . $sub . ')';
break; break;
case "collection": case "collection":
$sub = substr(str_repeat("?, ", $count),0,-2); $sub = substr(str_repeat("?, ", $count),0,-2);
...@@ -93,6 +88,7 @@ class Doctrine_Relation_Association extends Doctrine_Relation ...@@ -93,6 +88,7 @@ class Doctrine_Relation_Association extends Doctrine_Relation
} else { } else {
$coll = Doctrine_Query::create()->parseQuery($this->getRelationDql(1))->execute(array($id)); $coll = Doctrine_Query::create()->parseQuery($this->getRelationDql(1))->execute(array($id));
} }
$coll->setReference($record, $this);
return $coll; return $coll;
} }
} }
...@@ -67,8 +67,8 @@ class Address extends Doctrine_Record ...@@ -67,8 +67,8 @@ class Address extends Doctrine_Record
{ {
public function setUp() public function setUp()
{ {
$this->hasMany('User', array('local' => 'user_id', $this->hasMany('User', array('local' => 'address_id',
'foreign' => 'address_id', 'foreign' => 'user_id',
'refClass' => 'EntityAddress')); 'refClass' => 'EntityAddress'));
} }
public function setTableDefinition() { 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