mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 15:12:48 +08:00
改进
This commit is contained in:
@@ -439,7 +439,9 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
|||||||
$value = $this->readTransform($value, $this->type[$name]);
|
$value = $this->readTransform($value, $this->type[$name]);
|
||||||
} elseif ($notFound) {
|
} elseif ($notFound) {
|
||||||
$method = Loader::parseName($name, 1, false);
|
$method = Loader::parseName($name, 1, false);
|
||||||
if (method_exists($this, $method) && $this->$method()->removeOption() instanceof Relation) {
|
if (method_exists($this, $method) && $this->$method() instanceof Relation) {
|
||||||
|
// 清空之前的查询参数
|
||||||
|
$this->$method()->removeOption();
|
||||||
// 不存在该字段 获取关联数据
|
// 不存在该字段 获取关联数据
|
||||||
$value = $this->$method()->getRelation();
|
$value = $this->$method()->getRelation();
|
||||||
// 保存关联对象值
|
// 保存关联对象值
|
||||||
|
|||||||
@@ -1000,16 +1000,16 @@ class Query
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 去除某个查询参数
|
* 去除查询参数
|
||||||
* @access public
|
* @access public
|
||||||
* @param string $option 参数名
|
* @param string|bool $option 参数名 true 表示去除所有参数
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function removeOption($option = '')
|
public function removeOption($option = true)
|
||||||
{
|
{
|
||||||
if ('' === $option) {
|
if (true === $option) {
|
||||||
$this->options = [];
|
$this->options = [];
|
||||||
} elseif (isset($this->options[$option])) {
|
} elseif (is_string($option) && isset($this->options[$option])) {
|
||||||
unset($this->options[$option]);
|
unset($this->options[$option]);
|
||||||
}
|
}
|
||||||
return $this;
|
return $this;
|
||||||
@@ -1660,7 +1660,7 @@ class Query
|
|||||||
|
|
||||||
/** @var Relation $model */
|
/** @var Relation $model */
|
||||||
$relation = Loader::parseName($relation, 1, false);
|
$relation = Loader::parseName($relation, 1, false);
|
||||||
$model = $class->$relation()->removeOption();
|
$model = $class->$relation();
|
||||||
if ($model instanceof OneToOne && 0 == $model->getEagerlyType()) {
|
if ($model instanceof OneToOne && 0 == $model->getEagerlyType()) {
|
||||||
$model->eagerly($this, $relation, $subRelation, $closure, $first);
|
$model->eagerly($this, $relation, $subRelation, $closure, $first);
|
||||||
$first = false;
|
$first = false;
|
||||||
|
|||||||
@@ -160,6 +160,7 @@ abstract class OneToOne extends Relation
|
|||||||
*/
|
*/
|
||||||
public function getEagerlyType()
|
public function getEagerlyType()
|
||||||
{
|
{
|
||||||
|
$this->removeOption();
|
||||||
return $this->eagerlyType;
|
return $this->eagerlyType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user