内核更新
This commit is contained in:
@@ -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 数据库查询对象实例
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
Reference in New Issue
Block a user