mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-06 15:02:47 +08:00
改进模型的字段信息定义第二次查询不生效的问题
This commit is contained in:
@@ -41,6 +41,12 @@ class Query
|
|||||||
protected $table = '';
|
protected $table = '';
|
||||||
// 当前数据表名称(不含前缀)
|
// 当前数据表名称(不含前缀)
|
||||||
protected $name = '';
|
protected $name = '';
|
||||||
|
// 当前数据表主键
|
||||||
|
protected $pk;
|
||||||
|
// 当前表字段类型信息
|
||||||
|
protected $fieldType;
|
||||||
|
// 当前允许的字段列表
|
||||||
|
protected $allowField;
|
||||||
// 当前数据表前缀
|
// 当前数据表前缀
|
||||||
protected $prefix = '';
|
protected $prefix = '';
|
||||||
// 查询参数
|
// 查询参数
|
||||||
@@ -727,11 +733,11 @@ class Query
|
|||||||
}
|
}
|
||||||
if (true === $field) {
|
if (true === $field) {
|
||||||
// 获取全部字段
|
// 获取全部字段
|
||||||
$fields = isset($this->options['allow_field']) ? $this->options['allow_field'] : $this->getTableInfo($tableName ?: (isset($this->options['table']) ? $this->options['table'] : ''), 'fields');
|
$fields = isset($this->allowField) ? $this->allowField : $this->getTableInfo($tableName ?: (isset($this->options['table']) ? $this->options['table'] : ''), 'fields');
|
||||||
$field = $fields ?: ['*'];
|
$field = $fields ?: ['*'];
|
||||||
} elseif ($except) {
|
} elseif ($except) {
|
||||||
// 字段排除
|
// 字段排除
|
||||||
$fields = isset($this->options['allow_field']) ? $this->options['allow_field'] : $this->getTableInfo($tableName ?: (isset($this->options['table']) ? $this->options['table'] : ''), 'fields');
|
$fields = isset($this->allowField) ? $this->allowField : $this->getTableInfo($tableName ?: (isset($this->options['table']) ? $this->options['table'] : ''), 'fields');
|
||||||
$field = $fields ? array_diff($fields, $field) : $field;
|
$field = $fields ? array_diff($fields, $field) : $field;
|
||||||
}
|
}
|
||||||
if ($tableName) {
|
if ($tableName) {
|
||||||
@@ -1255,7 +1261,7 @@ class Query
|
|||||||
} elseif (is_string($field)) {
|
} elseif (is_string($field)) {
|
||||||
$field = explode(',', $field);
|
$field = explode(',', $field);
|
||||||
}
|
}
|
||||||
$this->options['allow_field'] = $field;
|
$this->allowField = $field;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1267,7 +1273,7 @@ class Query
|
|||||||
*/
|
*/
|
||||||
public function setFieldType($fieldType = [])
|
public function setFieldType($fieldType = [])
|
||||||
{
|
{
|
||||||
$this->options['field_type'] = $fieldType;
|
$this->fieldType = $fieldType;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1279,7 +1285,7 @@ class Query
|
|||||||
*/
|
*/
|
||||||
public function pk($pk)
|
public function pk($pk)
|
||||||
{
|
{
|
||||||
$this->options['pk'] = $pk;
|
$this->pk = $pk;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1387,10 +1393,8 @@ class Query
|
|||||||
*/
|
*/
|
||||||
public function getPk($options = '')
|
public function getPk($options = '')
|
||||||
{
|
{
|
||||||
if (!empty($options['pk'])) {
|
if (!empty($this->pk)) {
|
||||||
$pk = $options['pk'];
|
$pk = $this->pk;
|
||||||
} elseif (isset($this->options['pk'])) {
|
|
||||||
$pk = $this->options['pk'];
|
|
||||||
} else {
|
} else {
|
||||||
$pk = $this->getTableInfo(is_array($options) ? $options['table'] : $options, 'pk');
|
$pk = $this->getTableInfo(is_array($options) ? $options['table'] : $options, 'pk');
|
||||||
}
|
}
|
||||||
@@ -1400,13 +1404,13 @@ class Query
|
|||||||
// 获取当前数据表字段信息
|
// 获取当前数据表字段信息
|
||||||
public function getTableFields($options)
|
public function getTableFields($options)
|
||||||
{
|
{
|
||||||
return !empty($options['allow_field']) ? $options['allow_field'] : $this->getTableInfo($options['table'], 'fields');
|
return !empty($this->allowField) ? $this->allowField : $this->getTableInfo($options['table'], 'fields');
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取当前数据表字段类型
|
// 获取当前数据表字段类型
|
||||||
public function getFieldsType($options)
|
public function getFieldsType($options)
|
||||||
{
|
{
|
||||||
return !empty($options['field_type']) ? $options['field_type'] : $this->getTableInfo($options['table'], 'type');
|
return !empty($this->fieldType) ? $this->fieldType : $this->getTableInfo($options['table'], 'type');
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取当前数据表绑定信息
|
// 获取当前数据表绑定信息
|
||||||
|
|||||||
Reference in New Issue
Block a user