Set the constraints for an eager load of the relation.

@param array $results

@return void
359384
public function addEagerConstraints(array $results)
    {
        // We'll grab the primary key name of the related models since it could be set to
        // a non-standard name and not "id". We will then construct the constraint for
        // our eagerly loading query so it returns the proper models from execution.
        $key = $this->otherKey;

        $this->query->whereIn($key, $this->getEagerModelKeys($results));
    }
358349
public function setResult(&$result) {
        if (!is_null($result) &&
            !$result instanceof Garp_Db_Table_Row &&
            !$result instanceof Garp_Db_Table_Rowset) {
                throw new InvalidArgumentException(__METHOD__.' expects parameter 1 to be a'.
                    'Garp_Db_Table_Row or Garp_Db_Table_Rowset. '.gettype($result).' given.');
        }
        $this->_result = $result;
    }
1364738
public function eagerLoadRelations(array $results): array
    {
        foreach ($this->eagerLoads as $name => $constraints) {
            // First, we'll check if the entity map has a relation and just pass if it
            // is not the case

            if (!in_array($name, $this->entityMap->getRelationships())) {
                continue;
            }

            // For nested eager loads we'll skip loading them here and they will be set as an
            // eager load on the query to retrieve the relation so that they will be eager
            // loaded on that query, because that is where they get hydrated as models.
            if (strpos($name, '.') === false) {
                $results = $this->loadRelation($results, $name, $constraints);
            }
        }

        return $results;
    }
787700
public function processColumnListing($results)
    {
        $mapping = function ($r) {
            $r = (object) $r;

            return $r->column_name;
        };

        return array_map($mapping, $results);
    }
111564
protected function buildDictionary(array $results)
    {
        // First we will build a dictionary of child models keyed by the foreign key
        // of the relation so that we will easily and quickly match them to their
        // parents without having a possibly slow inner loops for every models.
        $dictionary = [];

        foreach ($results as $result) {
            $dictionary[$result->pivot->{$this->foreignKey}][] = $result;
        }

        return $dictionary;
    }
1076486
protected function buildUnkeyedResultSet(array $results) : array
    {
        $builder = new EntityBuilder($this->mapper, array_keys($this->eagerLoads), $this->useCache);

        return array_map(function ($item) use ($builder) {
            return $builder->build($item);
        }, $results);
    }
570761
public function setConstraints($constraints)
    {
        foreach ($constraints as $fieldName => $v) {
            if (is_array($v)) {
                foreach ($v as $constraintFromArray) {
                    $this->setConstraint($fieldName, $constraintFromArray);
                }
            } else {
                $this->setConstraint($fieldName, $v);
            }
        }

        return $this;
    }
231195
public function build(array $results, array $eagerLoads)
    {
        // First, we'll cache the raw result set
        $this->cacheResults($results);

        // Parse embedded relations and build corresponding entities using the default
        // mapper.
        $results = $this->buildEmbeddedRelationships($results);

        // Launch the queries related to eager loads, and match the
        // current result set to these loaded relationships.
        $results = $this->queryEagerLoadedRelationships($results, $eagerLoads);

        return $this->buildResultSet($results);
    }
451402
protected function fillArrayWithRecords( array &$results, array $records, $limit, $offset )
    {
        $length = min( count( $records ), $limit );

        $index = 0;

        foreach ($records as $record) {
            $offset += $this->fillArrayWithSingleRecord( $results, $record, $offset );

            $index++;

            if ($index >= $length) {
                break;
            }
        }
    }
1257071
public function addConstraints()
    {
        if (static::$constraints)
        {
            $this->query->where($this->foreignKey, '=', $this->getParentKey());

            $this->query->whereNotNull($this->foreignKey);

            $this->query->where($this->rootKey, '=', $this->getRootKey());

            $this->query->whereNotNull($this->rootKey);

        }
    }
351337
public function setResult($result = null)
    {
        $this->result = $result;
        $this->state = self::STATE_DONE;
        if ($this->listeners) {
            $this->listeners->executeAll($this->result);
        }
    }
360465
public function addEagerConstraints(array $models)
    {
        $whereIn = $this->whereInMethod($this->parent, $this->parentKey);

        $this->query->{$whereIn}(
            $this->getQualifiedForeignPivotKeyName(),
            $this->getKeys($models, $this->parentKey)
        );
    }
74876
public function setResult($result): self
    {
        $this->_result = $result;
        $this->_hasResult = true;

        return $this;
    }
520382
protected function loadRelation(array $results, string $name, Closure $constraints) : array
    {
        // First we will "back up" the existing where conditions on the query so we can
        // add our eager constraints. Then we will merge the wheres that were on the
        // query back to it in order that any where conditions might be specified.
        $relation = $this->getRelation($name);

        $relation->addEagerConstraints($results);

        call_user_func($constraints, $relation);

        // Once we have the results, we just match those back up to their parent models
        // using the relationship instance. Then we just return the finished arrays
        // of models which have been eagerly hydrated and are readied for return.
        return $relation->match($results, $name);
    }
968384
protected function setFieldResults(array $fieldResults)
    {
        foreach ($fieldResults as $fieldName => $validationResult) {
            $this->setFieldResult($fieldName, $validationResult);
        }
    }
407756
protected function buildEmbeddedRelationships(array $results) : array
    {
        $entityMap = $this->entityMap;
        $instance = $this->mapper->newInstance();
        $embeddeds = $entityMap->getEmbeddedRelationships();

        foreach ($embeddeds as $embedded) {
            $results = $entityMap->$embedded($instance)->match($results, $embedded);
        }

        return $results;
    }
1130460
public function setResult($name = null, $result = null)
    {
        if (null === $result) {
            $result = $name;
            array_push($this->results, $result);

            return $this;
        }

        $this->results[(string) $name] = $result;

        return $this;
    }