yii\db\BaseActiveRecord::bindModels PHP Method

bindModels() private method

private bindModels ( array $link, yii\db\ActiveRecordInterface $foreignModel, yii\db\ActiveRecordInterface $primaryModel )
$link array
$foreignModel yii\db\ActiveRecordInterface
$primaryModel yii\db\ActiveRecordInterface
    private function bindModels($link, $foreignModel, $primaryModel)
    {
        foreach ($link as $fk => $pk) {
            $value = $primaryModel->{$pk};
            if ($value === null) {
                throw new InvalidCallException('Unable to link models: the primary key of ' . get_class($primaryModel) . ' is null.');
            }
            if (is_array($foreignModel->{$fk})) {
                // relation via array valued attribute
                $foreignModel->{$fk} = array_merge($foreignModel->{$fk}, [$value]);
            } else {
                $foreignModel->{$fk} = $value;
            }
        }
        $foreignModel->save(false);
    }