mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-08 23:52:49 +08:00
Query类value和column增加对调用field链式操作方法的处理
This commit is contained in:
@@ -107,6 +107,9 @@ class Query
|
|||||||
$result = Cache::get($key);
|
$result = Cache::get($key);
|
||||||
}
|
}
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
|
if (isset($this->options['field'])) {
|
||||||
|
unset($this->options['field']);
|
||||||
|
}
|
||||||
$pdo = $this->field($field)->fetchPdo(true)->find();
|
$pdo = $this->field($field)->fetchPdo(true)->find();
|
||||||
$result = $pdo->fetchColumn();
|
$result = $pdo->fetchColumn();
|
||||||
if (isset($cache)) {
|
if (isset($cache)) {
|
||||||
@@ -137,6 +140,9 @@ class Query
|
|||||||
$result = Cache::get($guid);
|
$result = Cache::get($guid);
|
||||||
}
|
}
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
|
if (isset($this->options['field'])) {
|
||||||
|
unset($this->options['field']);
|
||||||
|
}
|
||||||
if ($key && '*' != $field) {
|
if ($key && '*' != $field) {
|
||||||
$field = $key . ',' . $field;
|
$field = $key . ',' . $field;
|
||||||
}
|
}
|
||||||
@@ -365,7 +371,7 @@ class Query
|
|||||||
}
|
}
|
||||||
if (count($join)) {
|
if (count($join)) {
|
||||||
// 有设置第二个元素则把第二元素作为表前缀
|
// 有设置第二个元素则把第二元素作为表前缀
|
||||||
$table = (string)current($join) . $table;
|
$table = (string) current($join) . $table;
|
||||||
} elseif (false === strpos($table, '.')) {
|
} elseif (false === strpos($table, '.')) {
|
||||||
// 加上默认的表前缀
|
// 加上默认的表前缀
|
||||||
$table = $prefix . $table;
|
$table = $prefix . $table;
|
||||||
@@ -497,7 +503,7 @@ class Query
|
|||||||
protected function parseWhereExp($operator, $field, $op, $condition, $param = [])
|
protected function parseWhereExp($operator, $field, $op, $condition, $param = [])
|
||||||
{
|
{
|
||||||
if ($field instanceof \Closure) {
|
if ($field instanceof \Closure) {
|
||||||
call_user_func_array($field, [& $this]);
|
call_user_func_array($field, [ & $this]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -640,16 +646,15 @@ class Query
|
|||||||
|
|
||||||
$class = (!empty($config['namespace']) ? $config['namespace'] : '\\think\\paginator\\driver\\') . ucwords($config['type']);
|
$class = (!empty($config['namespace']) ? $config['namespace'] : '\\think\\paginator\\driver\\') . ucwords($config['type']);
|
||||||
|
|
||||||
$page = isset($config['page']) ? (int)$config['page'] : call_user_func([
|
$page = isset($config['page']) ? (int) $config['page'] : call_user_func([
|
||||||
$class,
|
$class,
|
||||||
'getCurrentPage'
|
'getCurrentPage',
|
||||||
], $config['var_page']);
|
], $config['var_page']);
|
||||||
|
|
||||||
$page = $page < 1 ? 1 : $page;
|
$page = $page < 1 ? 1 : $page;
|
||||||
|
|
||||||
$config['path'] = isset($config['path']) ? $config['path'] : call_user_func([$class, 'getCurrentPath']);
|
$config['path'] = isset($config['path']) ? $config['path'] : call_user_func([$class, 'getCurrentPath']);
|
||||||
|
|
||||||
|
|
||||||
/** @var Paginator $paginator */
|
/** @var Paginator $paginator */
|
||||||
if (!$simple) {
|
if (!$simple) {
|
||||||
$options = $this->getOptions();
|
$options = $this->getOptions();
|
||||||
@@ -1074,7 +1079,7 @@ class Query
|
|||||||
$this->join($joinTable . ' ' . $joinName, $name . '.' . $info['localKey'] . '=' . $joinName . '.' . $info['foreignKey'])->field(true, false, $joinTable, $joinName, $joinName . '__');
|
$this->join($joinTable . ' ' . $joinName, $name . '.' . $info['localKey'] . '=' . $joinName . '.' . $info['foreignKey'])->field(true, false, $joinTable, $joinName, $joinName . '__');
|
||||||
if ($closure) {
|
if ($closure) {
|
||||||
// 执行闭包查询
|
// 执行闭包查询
|
||||||
call_user_func_array($closure, [& $this]);
|
call_user_func_array($closure, [ & $this]);
|
||||||
}
|
}
|
||||||
$i++;
|
$i++;
|
||||||
} elseif ($closure) {
|
} elseif ($closure) {
|
||||||
@@ -1275,7 +1280,7 @@ class Query
|
|||||||
if ($data instanceof Query) {
|
if ($data instanceof Query) {
|
||||||
return $data->select();
|
return $data->select();
|
||||||
} elseif ($data instanceof \Closure) {
|
} elseif ($data instanceof \Closure) {
|
||||||
call_user_func_array($data, [& $this]);
|
call_user_func_array($data, [ & $this]);
|
||||||
}
|
}
|
||||||
// 分析查询表达式
|
// 分析查询表达式
|
||||||
$options = $this->parseExpress();
|
$options = $this->parseExpress();
|
||||||
@@ -1358,7 +1363,7 @@ class Query
|
|||||||
if ($data instanceof Query) {
|
if ($data instanceof Query) {
|
||||||
return $data->find();
|
return $data->find();
|
||||||
} elseif ($data instanceof \Closure) {
|
} elseif ($data instanceof \Closure) {
|
||||||
call_user_func_array($data, [& $this]);
|
call_user_func_array($data, [ & $this]);
|
||||||
}
|
}
|
||||||
// 分析查询表达式
|
// 分析查询表达式
|
||||||
$options = $this->parseExpress();
|
$options = $this->parseExpress();
|
||||||
|
|||||||
Reference in New Issue
Block a user