From ee44a1423ab2e3039abbd0ab8f9f01941cea193e Mon Sep 17 00:00:00 2001 From: thinkphp Date: Sun, 17 Nov 2019 16:20:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=E4=B8=80=E5=A4=84PHP7.4?= =?UTF-8?q?=E5=85=BC=E5=AE=B9=E6=80=A7=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/db/Query.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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; } // 当设置的分表字段不在查询条件或者数据中