内核更新

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

@@ -32,7 +32,7 @@ abstract class Builder
protected $deleteSql = 'DELETE FROM %TABLE% %USING% %JOIN% %WHERE% %ORDER%%LIMIT% %LOCK%%COMMENT%';
/**
* 构函数
* 构函数
* @access public
* @param Connection $connection 数据库连接对象实例
* @param Query $query 数据库查询对象实例

View File

@@ -125,7 +125,7 @@ abstract class Connection
protected $bind = [];
/**
* 构函数 读取数据库配置信息
* 构函数 读取数据库配置信息
* @access public
* @param array $config 数据库配置数组
*/
@@ -365,8 +365,8 @@ abstract class Connection
$this->bind = $bind;
}
//释放前次的查询结果
if (!empty($this->PDOStatement) && $this->PDOStatement->queryString != $sql) {
// 释放前次的查询结果
if (!empty($this->PDOStatement)) {
$this->free();
}

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);

View File

@@ -38,6 +38,8 @@ class Mysql extends Builder
list($table, $key) = explode('.', $key, 2);
if (isset($options['alias'][$table])) {
$table = $options['alias'][$table];
} elseif ('__TABLE__' == $table) {
$table = $this->query->getTable();
}
}
if (!preg_match('/[,\'\"\*\(\)`.\s]/', $key)) {

View File

@@ -57,6 +57,8 @@ class Pgsql extends Builder
list($table, $key) = explode('.', $key, 2);
if (isset($options['alias'][$table])) {
$table = $options['alias'][$table];
} elseif ('__TABLE__' == $table) {
$table = $this->query->getTable();
}
}
if (isset($table)) {

View File

@@ -62,6 +62,8 @@ class Sqlite extends Builder
list($table, $key) = explode('.', $key, 2);
if (isset($options['alias'][$table])) {
$table = $options['alias'][$table];
} elseif ('__TABLE__' == $table) {
$table = $this->query->getTable();
}
}
if (isset($table)) {

View File

@@ -75,6 +75,8 @@ class Sqlsrv extends Builder
list($table, $key) = explode('.', $key, 2);
if (isset($options['alias'][$table])) {
$table = $options['alias'][$table];
} elseif ('__TABLE__' == $table) {
$table = $this->query->getTable();
}
}
if (!is_numeric($key) && !preg_match('/[,\'\"\*\(\)\[.\s]/', $key)) {