改进Relation类 支持关联的新增

This commit is contained in:
thinkphp
2016-04-20 08:33:23 +08:00
parent dc40fac651
commit b599829e75
3 changed files with 73 additions and 20 deletions

View File

@@ -850,8 +850,8 @@ class Query
$this->table($joinTable)->alias($joinName)->field(true, false, $joinTable, $joinName);
}
// 预载入封装
$table = $model::getTableName();
$name = strtolower(basename(str_replace('\\', '/', $model)));
$table = $info['model']::getTableName();
$name = strtolower(basename(str_replace('\\', '/', $info['model'])));
$this->via($name);
$this->join($table . ' ' . $name, $joinName . '.' . $info['localKey'] . '=' . $name . '.' . $info['foreignKey'])->field(true, false, $table, $name, $name . '__');
if ($closure) {