mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-06 15:02:47 +08:00
改进
This commit is contained in:
@@ -2361,8 +2361,8 @@ class Query
|
|||||||
if (count($resultSet) > 0) {
|
if (count($resultSet) > 0) {
|
||||||
foreach ($resultSet as $key => $result) {
|
foreach ($resultSet as $key => $result) {
|
||||||
/** @var Model $model */
|
/** @var Model $model */
|
||||||
$model = new $modelName();
|
$model = new $modelName($result);
|
||||||
$model->data($result)->isUpdate(true);
|
$model->isUpdate(true);
|
||||||
|
|
||||||
// 关联查询
|
// 关联查询
|
||||||
if (!empty($options['relation'])) {
|
if (!empty($options['relation'])) {
|
||||||
@@ -2518,8 +2518,8 @@ class Query
|
|||||||
if (!empty($this->model)) {
|
if (!empty($this->model)) {
|
||||||
// 返回模型对象
|
// 返回模型对象
|
||||||
$model = $this->model;
|
$model = $this->model;
|
||||||
$result = new $model();
|
$result = new $model($result);
|
||||||
$result->data($result)->isUpdate(true, isset($options['where']['AND']) ? $options['where']['AND'] : null);
|
$result->isUpdate(true, isset($options['where']['AND']) ? $options['where']['AND'] : null);
|
||||||
// 关联查询
|
// 关联查询
|
||||||
if (!empty($options['relation'])) {
|
if (!empty($options['relation'])) {
|
||||||
$result->relationQuery($options['relation']);
|
$result->relationQuery($options['relation']);
|
||||||
|
|||||||
@@ -24,11 +24,11 @@ class Pivot extends Model
|
|||||||
/**
|
/**
|
||||||
* 架构函数
|
* 架构函数
|
||||||
* @access public
|
* @access public
|
||||||
* @param Model $parent 上级模型
|
|
||||||
* @param array|object $data 数据
|
* @param array|object $data 数据
|
||||||
|
* @param Model $parent 上级模型
|
||||||
* @param string $table 中间数据表名
|
* @param string $table 中间数据表名
|
||||||
*/
|
*/
|
||||||
public function __construct(Model $parent = null, $data = [], $table = '')
|
public function __construct($data = [], Model $parent = null, $table = '')
|
||||||
{
|
{
|
||||||
$this->parent = $parent;
|
$this->parent = $parent;
|
||||||
|
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ class BelongsToMany extends Relation
|
|||||||
protected function newPivot($data = [])
|
protected function newPivot($data = [])
|
||||||
{
|
{
|
||||||
$class = $this->pivotName ?: '\\think\\model\\Pivot';
|
$class = $this->pivotName ?: '\\think\\model\\Pivot';
|
||||||
$pivot = new $class($this->parent, $data, $this->middle);
|
$pivot = new $class($data, $this->parent, $this->middle);
|
||||||
if ($pivot instanceof Pivot) {
|
if ($pivot instanceof Pivot) {
|
||||||
return $pivot;
|
return $pivot;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user