This commit is contained in:
thinkphp
2018-04-12 11:19:32 +08:00
parent 8ae0fdef46
commit b18863749e

View File

@@ -769,7 +769,11 @@ class Query
{ {
if (empty($field)) { if (empty($field)) {
return $this; return $this;
} elseif ($field instanceof Expression) {
$this->options['field'][] = $field;
return $this;
} }
if (is_string($field)) { if (is_string($field)) {
$field = array_map('trim', explode(',', $field)); $field = array_map('trim', explode(',', $field));
} }
@@ -1485,7 +1489,13 @@ class Query
*/ */
public function order($field, $order = null) public function order($field, $order = null)
{ {
if (!empty($field)) { if (empty($field)) {
return $this;
} elseif ($field instanceof Expression) {
$this->options['order'][] = $field;
return $this;
}
if (is_string($field)) { if (is_string($field)) {
if (!empty($this->options['via'])) { if (!empty($this->options['via'])) {
$field = $this->options['via'] . '.' . $field; $field = $this->options['via'] . '.' . $field;
@@ -1509,7 +1519,7 @@ class Query
} else { } else {
$this->options['order'][] = $field; $this->options['order'][] = $field;
} }
}
return $this; return $this;
} }