目录结构调整

This commit is contained in:
2016-06-30 16:53:58 +08:00
parent 7eaa319115
commit 52f669abec
107 changed files with 4600 additions and 476 deletions

View File

@@ -776,8 +776,13 @@ class Query
$fields[] = $alias . '.' . $val;
$this->options['map'][$val] = $alias . '.' . $val;
} else {
$fields[] = $alias . '.' . $key . ' AS ' . $val;
$this->options['map'][$val] = $alias . '.' . $key;
if (preg_match('/[,=\.\'\"\(\s]/', $key)) {
$name = $key;
} else {
$name = $alias . '.' . $key;
}
$fields[] = $name . ' AS ' . $val;
$this->options['map'][$val] = $name;
}
}
}
@@ -1661,6 +1666,7 @@ class Query
// 如果存在主键数据 则自动作为更新条件
if (is_string($pk) && isset($data[$pk])) {
$where[$pk] = $data[$pk];
$key = 'think:' . $options['table'] . '|' . $data[$pk];
unset($data[$pk]);
} elseif (is_array($pk)) {
// 增加复合主键支持
@@ -1687,6 +1693,11 @@ class Query
// 获取实际执行的SQL语句
return $this->connection->getRealSql($sql, $this->bind);
} else {
// 检测缓存
if (isset($key) && Cache::get($key)) {
// 删除缓存
Cache::rm($key);
}
// 执行操作
return '' == $sql ? 0 : $this->execute($sql, $this->getBind());
}
@@ -1808,8 +1819,12 @@ class Query
$result = false;
if (empty($options['fetch_sql']) && !empty($options['cache'])) {
// 判断查询缓存
$cache = $options['cache'];
$key = is_string($cache['key']) ? $cache['key'] : md5(serialize($options));
$cache = $options['cache'];
if (true === $cache['key'] && !is_array($data)) {
$key = 'think:' . $options['table'] . '|' . $data;
} else {
$key = is_string($cache['key']) ? $cache['key'] : md5(serialize($options));
}
$result = Cache::get($key);
}
if (!$result) {
@@ -1959,6 +1974,10 @@ class Query
$options = $this->parseExpress();
if (!is_null($data) && true !== $data) {
if (!is_array($data)) {
// 缓存标识
$key = 'think:' . $options['table'] . '|' . $data;
}
// AR模式分析主键条件
$this->parsePkWhere($data, $options);
}
@@ -1969,10 +1988,17 @@ class Query
}
// 生成删除SQL语句
$sql = $this->builder()->delete($options);
if ($options['fetch_sql']) {
// 获取实际执行的SQL语句
return $this->connection->getRealSql($sql, $this->bind);
}
// 检测缓存
if (isset($key) && Cache::get($key)) {
// 删除缓存
Cache::rm($key);
}
// 执行操作
return $this->execute($sql, $this->getBind());
}