Prado\Data\ActiveRecord\Relations\TActiveRecordHasManyAssociation::fetchForeignObjects PHP Method

fetchForeignObjects() protected method

Fetches the foreign objects using TActiveRecord::findAllByIndex()
protected fetchForeignObjects ( &$results, $foreignKeys, $indexValues, $sourceKeys )
    protected function fetchForeignObjects(&$results, $foreignKeys, $indexValues, $sourceKeys)
    {
        $criteria = $this->getCriteria();
        $finder = $this->getContext()->getForeignRecordFinder();
        $type = get_class($finder);
        $command = $this->createCommand($criteria, $foreignKeys, $indexValues, $sourceKeys);
        $srcProps = array_keys($sourceKeys);
        $collections = array();
        foreach ($this->getCommandBuilder()->onExecuteCommand($command, $command->query()) as $row) {
            $hash = $this->getObjectHash($row, $srcProps);
            foreach ($srcProps as $column) {
                unset($row[$column]);
            }
            $obj = $this->createFkObject($type, $row, $foreignKeys);
            $collections[$hash][] = $obj;
        }
        $this->setResultCollection($results, $collections, array_values($sourceKeys));
    }