mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 12:42:48 +08:00
改进Builder类的insertall方法
This commit is contained in:
@@ -340,13 +340,13 @@ abstract class Builder
|
||||
} else {
|
||||
$whereStr .= $exp . ' (' . $value . ')';
|
||||
}
|
||||
} elseif (in_array($exp, ['< TIME', '> TIME'])){
|
||||
$whereStr .= $key . ' ' . substr($exp,0,1) . ' ' . $this->parseDateTime($value, $field);
|
||||
} elseif (in_array($exp, ['BETWEEN TIME', 'NOT BETWEEN TIME'])){
|
||||
if(is_string($value)){
|
||||
$value = explode(',',$value);
|
||||
} elseif (in_array($exp, ['< TIME', '> TIME'])) {
|
||||
$whereStr .= $key . ' ' . substr($exp, 0, 1) . ' ' . $this->parseDateTime($value, $field);
|
||||
} elseif (in_array($exp, ['BETWEEN TIME', 'NOT BETWEEN TIME'])) {
|
||||
if (is_string($value)) {
|
||||
$value = explode(',', $value);
|
||||
}
|
||||
$whereStr .= $key . ' ' . substr($exp,0,-4) . $this->parseDateTime($value[0], $field) . ' AND ' . $this->parseDateTime($value[1], $field);
|
||||
$whereStr .= $key . ' ' . substr($exp, 0, -4) . $this->parseDateTime($value[0], $field) . ' AND ' . $this->parseDateTime($value[1], $field);
|
||||
}
|
||||
return $whereStr;
|
||||
}
|
||||
@@ -370,17 +370,17 @@ abstract class Builder
|
||||
{
|
||||
// 获取时间字段类型
|
||||
$type = $this->query->getTableInfo('', 'type');
|
||||
if(isset($type[$key])){
|
||||
if (isset($type[$key])) {
|
||||
$value = strtotime($value) ?: $value;
|
||||
if(preg_match('/(datetime|timestamp)/is', $type[$key])){
|
||||
if (preg_match('/(datetime|timestamp)/is', $type[$key])) {
|
||||
// 日期及时间戳类型
|
||||
$value = date('Y-m-d H:i:s', $value);
|
||||
}elseif(preg_match('/(date)/is', $type[$key])){
|
||||
} elseif (preg_match('/(date)/is', $type[$key])) {
|
||||
// 日期及时间戳类型
|
||||
$value = date('Y-m-d', $value);
|
||||
}
|
||||
}
|
||||
return is_int($value)? $value : $this->connection->quote($value);
|
||||
return is_int($value) ? $value : $this->connection->quote($value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -625,7 +625,7 @@ abstract class Builder
|
||||
$value = array_values($data);
|
||||
$values[] = 'SELECT ' . implode(',', $value);
|
||||
}
|
||||
$fields = array_map([$this, 'parseKey'], array_keys($dataSet[0]));
|
||||
$fields = array_map([$this, 'parseKey'], array_keys(reset($dataSet)));
|
||||
$sql = str_replace(
|
||||
['%TABLE%', '%FIELD%', '%DATA%', '%COMMENT%'],
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user