Skip to content

Commit

Permalink
Selection, GroupedSelection: updated getReferencingTable()
Browse files Browse the repository at this point in the history
  • Loading branch information
fabik committed Aug 26, 2012
1 parent 23be077 commit a11df6b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
18 changes: 10 additions & 8 deletions Database/GroupedSelection.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,19 +164,21 @@ protected function execute()
* Returns referencing rows.
* @param string
* @param string
* @param int primary key
* @param bool force new instance
* @param int primary key
* @return Nette\Database\Table\GroupedSelection
*/
public function getReferencingTable($table, $column, $active = NULL, $forceNewInstance = FALSE)
public function getReferencingTable($table, $column, $active = NULL)
{
$referencing = & $this->referencing["$table:$column"];
if (!$referencing || $forceNewInstance) {
$referencing = $this->createGroupedSelectionInstance($table, $column); // HACK
$prototype = & $this->getRefTable($refPath)->referencingPrototype[$refPath . "$table.$column"];
if (!$prototype) {
$prototype = $this->createGroupedSelectionInstance($table, $column);
$this->execute(); // HACK
$prototype->where("$table.$column", array_keys((array) $this->data)); // HACK
}

$this->execute(); // HACK
return $referencing->setActive($active)->where("$table.$column", array_keys((array) $this->data)); // HACK
$clone = clone $prototype;
$clone->setActive($active);
return $clone;
}


Expand Down
18 changes: 10 additions & 8 deletions Database/Selection.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,18 +81,20 @@ protected function createGroupedSelectionInstance($table, $column)
* Returns referencing rows.
* @param string
* @param string
* @param int primary key
* @param bool force new instance
* @param int primary key
* @return Nette\Database\Table\GroupedSelection
*/
public function getReferencingTable($table, $column, $active = NULL, $forceNewInstance = FALSE)
public function getReferencingTable($table, $column, $active = NULL)
{
$referencing = & $this->referencing["$table:$column"];
if (!$referencing || $forceNewInstance) {
$referencing = $this->createGroupedSelectionInstance($table, $column); // HACK
$prototype = & $this->getRefTable($refPath)->referencingPrototype[$refPath . "$table.$column"];
if (!$prototype) {
$prototype = $this->createGroupedSelectionInstance($table, $column);
$this->execute(); // HACK
$prototype->where("$table.$column", array_keys((array) $this->data)); // HACK
}

$this->execute(); // HACK
return $referencing->setActive($active)->where("$table.$column", array_keys((array) $this->data)); // HACK
$clone = clone $prototype;
$clone->setActive($active);
return $clone;
}
}

0 comments on commit a11df6b

Please sign in to comment.