framework/db/BaseActiveRecord.php
public function populateRelation($name, $records)
    {
        foreach ($this->_relationsDependencies as &$relationNames) {
            unset($relationNames[$name]);
        }

        $this->_related[$name] = $records;
    }
public function populateRelation($name, $records)
    {
        foreach ($this->_relationsDependencies as &$relationNames) {
            unset($relationNames[$name]);
        }

        $this->_related[$name] = $records;
    }
Populates the named relation with the related records.
Note that this method does not check if the relation exists or not.
@param string $name the relation name, e.g. `orders` for a relation defined via `getOrders()` method (case-sensitive).
@param ActiveRecordInterface|array|null $records the related records to be populated into the relation.
@see getRelation()