Skip to content

Commit

Permalink
Merge pull request #13 from Bazowsky/patch-1
Browse files Browse the repository at this point in the history
orderBy method chaining fix
  • Loading branch information
mychidarko authored Mar 5, 2024
2 parents 6d7cad8 + 99c8eaa commit aaa1ce3
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/Db/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,8 @@ public static function orderBy(
if (strpos($query, 'ORDER BY') === false) {
$query .= " ORDER BY $column " . strtoupper($direction);
} else {
$parts = explode('ORDER BY', $query);
$col = explode(' ', trim($parts[1]));
$parts[1] = str_replace($col[0], '', $parts[1]);

$query = implode("ORDER BY $column " . strtoupper($direction), $parts);
$parts = explode('ORDER BY ', $query);
$query = implode("ORDER BY $column " . strtoupper($direction) . ", ", $parts);
}

return $query;
Expand Down

0 comments on commit aaa1ce3

Please sign in to comment.