Skip to content

Commit 3e6bd1a

Browse files
committed
调整value和column方法 简化处理逻辑
1 parent 557bdeb commit 3e6bd1a

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/db/BaseQuery.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,9 @@ public function value(string $field, $default = null, bool $useModelAttr = false
375375
return $this->model->newInstance($array)->getAttr($field);
376376
}
377377

378-
$this->result($array);
378+
if (!empty($this->options['json'])) {
379+
$this->jsonResult($array);
380+
}
379381
return $array[$field];
380382
}
381383

@@ -413,7 +415,9 @@ public function column(string | array $field, string $key = '', bool $useModelAt
413415
}
414416
return $this->model->newInstance($item)->toArray();
415417
}
416-
$this->result($item);
418+
if (!empty($this->options['json'])) {
419+
$this->jsonResult($item);
420+
}
417421
return $item;
418422
}
419423

@@ -428,7 +432,9 @@ public function column(string | array $field, string $key = '', bool $useModelAt
428432
}
429433
return $this->model->newInstance($array)->getAttr($field);
430434
}
431-
$this->result($array);
435+
if (!empty($this->options['json'])) {
436+
$this->jsonResult($array);
437+
}
432438
return $array[$field];
433439
}, $result);
434440
}

0 commit comments

Comments
 (0)