改进Query类的view方法field参数支持使用sql函数

This commit is contained in:
thinkphp
2016-06-29 17:25:37 +08:00
parent b223dba490
commit 9e98ad237f

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