内核更新

This commit is contained in:
2017-02-14 09:41:34 +08:00
parent 689376a5d9
commit b355535009
43 changed files with 330 additions and 100 deletions

View File

@@ -54,7 +54,7 @@ class Query
private static $event = [];
/**
* 构函数
* 构函数
* @access public
* @param Connection $connection 数据库对象实例
* @param string $model 模型名
@@ -869,7 +869,7 @@ class Query
public function view($join, $field = true, $on = null, $type = 'INNER')
{
$this->options['view'] = true;
if (is_array($join) && is_null($field)) {
if (is_array($join) && key($join) !== 0) {
foreach ($join as $key => $val) {
$this->view($key, $val[0], isset($val[1]) ? $val[1] : null, isset($val[2]) ? $val[2] : 'INNER');
}
@@ -2065,8 +2065,10 @@ class Query
$sequence = $sequence ?: (isset($options['sequence']) ? $options['sequence'] : null);
$lastInsId = $this->getLastInsID($sequence);
if ($lastInsId) {
$pk = $this->getPk($options);
$data[$pk] = $lastInsId;
$pk = $this->getPk($options);
if (is_string($pk)) {
$data[$pk] = $lastInsId;
}
}
$options['data'] = $data;
$this->trigger('after_insert', $options);
@@ -2202,6 +2204,8 @@ class Query
if (isset($key) && Cache::get($key)) {
// 删除缓存
Cache::rm($key);
} elseif (!empty($options['cache']['tag'])) {
Cache::clear($options['cache']['tag']);
}
// 执行操作
$result = '' == $sql ? 0 : $this->execute($sql, $bind);
@@ -2375,6 +2379,8 @@ class Query
}
if (isset($data)) {
return 'think:' . $options['table'] . '|' . $data;
} else {
return md5(serialize($options));
}
}
@@ -2412,8 +2418,10 @@ class Query
$cache = $options['cache'];
if (true === $cache['key'] && !is_null($data) && !is_array($data)) {
$key = 'think:' . (is_array($options['table']) ? key($options['table']) : $options['table']) . '|' . $data;
} elseif (is_string($cache['key'])) {
$key = $cache['key'];
} elseif (!isset($key)) {
$key = is_string($cache['key']) ? $cache['key'] : md5(serialize($options));
$key = md5(serialize($options));
}
$result = Cache::get($key);
}
@@ -2644,6 +2652,8 @@ class Query
if (isset($key) && Cache::get($key)) {
// 删除缓存
Cache::rm($key);
} elseif (!empty($options['cache']['tag'])) {
Cache::clear($options['cache']['tag']);
}
// 执行操作
$result = $this->execute($sql, $bind);