📦 更新拓展包及框架

This commit is contained in:
WispX
2020-01-08 11:24:11 +08:00
parent 08166e2044
commit 58b5956a15
116 changed files with 1929 additions and 1693 deletions
+26 -6
View File
@@ -133,7 +133,27 @@ class Query
*/
public function newQuery()
{
return new static($this->connection);
$query = new static($this->connection);
if ($this->model) {
$query->model($this->model);
}
if (isset($this->options['table'])) {
$query->table($this->options['table']);
} else {
$query->name($this->name);
}
if (isset($this->options['json'])) {
$query->json($this->options['json'], $this->options['json_assoc']);
}
if (isset($this->options['field_type'])) {
$query->setJsonFieldType($this->options['field_type']);
}
return $query;
}
/**
@@ -562,12 +582,12 @@ class Query
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;
}
// 当设置的分表字段不在查询条件或者数据中
@@ -2470,7 +2490,7 @@ class Query
if (is_array($value)) {
$this->bind = array_merge($this->bind, $value);
} else {
$name = $name ?: 'ThinkBind_' . (count($this->bind) + 1) . '_';
$name = $name ?: 'ThinkBind_' . (count($this->bind) + 1) . '_' . mt_rand() . '_';
$this->bind[$name] = [$value, $type];
return $name;