Merge pull request #458 from hldh214/patch-2

修复闭包查询条件为空导致的 sql 语法错误
This commit is contained in:
ThinkPHP
2017-01-30 08:19:21 +08:00
committed by GitHub

View File

@@ -250,7 +250,10 @@ abstract class Builder
// 使用闭包查询
$query = new Query($this->connection);
call_user_func_array($value, [ & $query]);
$str[] = ' ' . $key . ' ( ' . $this->buildWhere($query->getOptions('where'), $options) . ' )';
$whereClause = $this->buildWhere($query->getOptions('where'), $options);
if (!empty($whereClause)) {
$str[] = ' ' . $key . ' ( ' . $whereClause . ' )';
}
} elseif (strpos($field, '|')) {
// 不同字段使用相同查询条件OR
$array = explode('|', $field);