public function retrieveReferenced(IRecord $record) { if ($record->getState() === IRecord::STATE_NEW) { return array(); } $cls = $this->referencedEntity; return $cls::findAll(array($this->column => $record->getPrimary())); }
public function retrieveReferenced(IRecord $record) { if ($record->getState() == IRecord::STATE_NEW) { return array(); } /* @var $db \DibiConnection */ $db = $this->mapper->getDb(); $ids = $db->select("%n", $this->referencedKey)->from("%n", $this->connectingTable)->where("%n = %i", $this->localKey, $record->getPrimary())->fetchPairs(); $class = $this->referencedEntity; return $class::findAll()->where("%n in %in", $class::getMapper()->getConfig()->getPrimaryColumn(), $ids); }