think\model\Relation::match PHP Метод

match() защищенный Метод

一对一 关联模型预查询拼装
protected match ( string $model, string $relation, Model &$result ) : void
$model string 模型名称
$relation string 关联名
$result think\Model 模型对象实例
Результат void
    protected function match($model, $relation, &$result)
    {
        // 重新组装模型数据
        foreach ($result->getData() as $key => $val) {
            if (strpos($key, '__')) {
                list($name, $attr) = explode('__', $key, 2);
                if ($name == $relation) {
                    $list[$name][$attr] = $val;
                    unset($result->{$key});
                }
            }
        }
        $result->setAttr($relation, !isset($list[$relation]) ? null : (new $model($list[$relation]))->isUpdate(true));
    }