Skip to content

Commit

Permalink
🔧 修復(Query.php):修正排序功能以支援多個排序條件
Browse files Browse the repository at this point in the history
  • Loading branch information
mathsgod committed Mar 14, 2024
1 parent 33ce625 commit 1952b9d
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,15 @@ public function sort(string $sort)
{
$query = clone $this;
if ($sort) {
$s = explode(':', $sort);
//custom order
if (isset(self::$Order[$this->class][$s[0]])) {
$query->order([self::$Order[$this->class][$s[0]]($s[1])]);
} else {
$query->order($s[0] . " " . $s[1]);
$sorts = explode(",", $sort);
foreach ($sorts as $sort) {
$s = explode(':', $sort);
//custom order
if (isset(self::$Order[$this->class][$s[0]])) {
$query->order([self::$Order[$this->class][$s[0]]($s[1])]);
} else {
$query->order($s[0] . " " . $s[1]);
}
}
}
return $query;
Expand Down

0 comments on commit 1952b9d

Please sign in to comment.