改进Query类的order方法

This commit is contained in:
thinkphp
2016-04-20 18:16:55 +08:00
parent 02934b0d27
commit 87a128f231

View File

@@ -610,10 +610,14 @@ class Query
$field = empty($order) ? $field : [$field => $order]; $field = empty($order) ? $field : [$field => $order];
} elseif (!empty($this->options['via'])) { } elseif (!empty($this->options['via'])) {
foreach ($field as $key => $val) { foreach ($field as $key => $val) {
if (is_numeric($key)) {
$field[$key] = $this->options['via'] . '.' . $val;
} else {
$field[$this->options['via'] . '.' . $key] = $val; $field[$this->options['via'] . '.' . $key] = $val;
unset($field[$key]); unset($field[$key]);
} }
} }
}
$this->options['order'] = $field; $this->options['order'] = $field;
} }
return $this; return $this;