mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 12:42:48 +08:00
改进
This commit is contained in:
@@ -769,7 +769,11 @@ class Query
|
||||
{
|
||||
if (empty($field)) {
|
||||
return $this;
|
||||
} elseif ($field instanceof Expression) {
|
||||
$this->options['field'][] = $field;
|
||||
return $this;
|
||||
}
|
||||
|
||||
if (is_string($field)) {
|
||||
$field = array_map('trim', explode(',', $field));
|
||||
}
|
||||
@@ -1485,31 +1489,37 @@ class Query
|
||||
*/
|
||||
public function order($field, $order = null)
|
||||
{
|
||||
if (!empty($field)) {
|
||||
if (is_string($field)) {
|
||||
if (!empty($this->options['via'])) {
|
||||
$field = $this->options['via'] . '.' . $field;
|
||||
}
|
||||
$field = empty($order) ? $field : [$field => $order];
|
||||
} elseif (!empty($this->options['via'])) {
|
||||
foreach ($field as $key => $val) {
|
||||
if (is_numeric($key)) {
|
||||
$field[$key] = $this->options['via'] . '.' . $val;
|
||||
} else {
|
||||
$field[$this->options['via'] . '.' . $key] = $val;
|
||||
unset($field[$key]);
|
||||
}
|
||||
}
|
||||
if (empty($field)) {
|
||||
return $this;
|
||||
} elseif ($field instanceof Expression) {
|
||||
$this->options['order'][] = $field;
|
||||
return $this;
|
||||
}
|
||||
|
||||
if (is_string($field)) {
|
||||
if (!empty($this->options['via'])) {
|
||||
$field = $this->options['via'] . '.' . $field;
|
||||
}
|
||||
if (!isset($this->options['order'])) {
|
||||
$this->options['order'] = [];
|
||||
}
|
||||
if (is_array($field)) {
|
||||
$this->options['order'] = array_merge($this->options['order'], $field);
|
||||
} else {
|
||||
$this->options['order'][] = $field;
|
||||
$field = empty($order) ? $field : [$field => $order];
|
||||
} elseif (!empty($this->options['via'])) {
|
||||
foreach ($field as $key => $val) {
|
||||
if (is_numeric($key)) {
|
||||
$field[$key] = $this->options['via'] . '.' . $val;
|
||||
} else {
|
||||
$field[$this->options['via'] . '.' . $key] = $val;
|
||||
unset($field[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isset($this->options['order'])) {
|
||||
$this->options['order'] = [];
|
||||
}
|
||||
if (is_array($field)) {
|
||||
$this->options['order'] = array_merge($this->options['order'], $field);
|
||||
} else {
|
||||
$this->options['order'][] = $field;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user