diff --git a/library/think/db/Query.php b/library/think/db/Query.php index 310ac659f0..0c3df89959 100644 --- a/library/think/db/Query.php +++ b/library/think/db/Query.php @@ -582,12 +582,12 @@ public function getPartitionTableName($data, $field, $rule = []) default: if (function_exists($type)) { // 支持指定函数哈希 - $seq = (ord(substr($type($value), 0, 1)) % $rule['num']) + 1; - } else { - // 按照字段的首字母的值分表 - $seq = (ord($value{0}) % $rule['num']) + 1; + $value = $type($value); } + + $seq = (ord(substr($value, 0, 1)) % $rule['num']) + 1; } + return $this->getTable() . '_' . $seq; } // 当设置的分表字段不在查询条件或者数据中