From 6977442b0578f2a6803ac6c5d4a0358b63525e71 Mon Sep 17 00:00:00 2001 From: JaguarJack Date: Wed, 17 Jun 2020 13:23:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E9=87=8D=E5=86=99Order=20?= =?UTF-8?q?=E6=96=B9=E6=B3=95=EF=BC=8C=E6=96=B0=E5=A2=9E=20CatchOrder?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extend/catcher/CatchQuery.php | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/extend/catcher/CatchQuery.php b/extend/catcher/CatchQuery.php index 18150e9..cd67141 100644 --- a/extend/catcher/CatchQuery.php +++ b/extend/catcher/CatchQuery.php @@ -187,35 +187,22 @@ class CatchQuery extends Query return parent::paginate($listRows, $simple); // TODO: Change the autogenerated stub } + /** - * order 排序 + * 默认排序 * - * @time 2020年04月30日 - * @param string $field + * @time 2020年06月17日 * @param string $order - * @param string $position - * @return $this|CatchQuery + * @return $this */ - public function order($field = '', string $order = 'desc', $position = 'backend') + public function catchOrder($order = 'desc') { - // 排序在前 - if ($position = 'front') { - parent::order($field, $order); - } if (in_array('sort', array_keys($this->getFields()))) { - parent::order('sort', $order); - } - // 紧跟权重的排序 - if ($position == 'middle') { - parent::order($field, $order); + $this->order($this->getTable() . '.sort', $order); } - parent::order($this->getPk(), $order); - // 最后插入排序 - if ($position == 'backend') { - parent::order($field, $order); - } + $this->order($this->getTable() . '.' . $this->getPk(), $order); - return $this; + return $this; } }