内核更新

This commit is contained in:
2016-09-01 22:03:02 +08:00
parent a12aba3512
commit 7381ce5ce7
15 changed files with 83 additions and 49 deletions

View File

@@ -908,9 +908,11 @@ class Query
$where = $field;
} elseif ($field) {
// 字符串查询
$where[] = ['exp', $field];
} else {
$where = '';
if (is_numeric($field)) {
$where[] = ['exp', $field];
} else {
$where[$field] = ['null', ''];
}
}
} elseif (is_array($op)) {
$where[$field] = $param;
@@ -1227,7 +1229,7 @@ class Query
/**
* 设置查询数据不存在是否抛出异常
* @access public
* @param bool $fail 是否严格检查字段
* @param bool $fail 数据不存在是否抛出异常
* @return $this
*/
public function failException($fail = true)
@@ -1855,7 +1857,8 @@ class Query
$resultSet = false;
if (empty($options['fetch_sql']) && !empty($options['cache'])) {
// 判断查询缓存
$cache = $options['cache'];
$cache = $options['cache'];
unset($options['cache']);
$key = is_string($cache['key']) ? $cache['key'] : md5(serialize($options));
$resultSet = Cache::get($key);
}
@@ -1883,7 +1886,7 @@ class Query
}
// 返回结果处理
if ($this->connection->getNumRows()) {
if (count($resultSet) > 0) {
// 数据列表读取后的处理
if (!empty($this->model)) {
// 生成模型对象

View File

@@ -31,6 +31,22 @@ class Sqlsrv extends Builder
*/
protected function parseOrder($order)
{
if (is_array($order)) {
$array = [];
foreach ($order as $key => $val) {
if (is_numeric($key)) {
if (false === strpos($val, '(')) {
$array[] = $this->parseKey($val);
} elseif ('[rand]' == $val) {
$array[] = $this->parseRand();
}
} else {
$sort = in_array(strtolower(trim($val)), ['asc', 'desc']) ? ' ' . $val : '';
$array[] = $this->parseKey($key) . ' ' . $sort;
}
}
$order = implode(',', $array);
}
return !empty($order) ? ' ORDER BY ' . $order : ' ORDER BY rand()';
}