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