Skip to content

Commit 0dba7e8

Browse files
committed
Add support for args in Query::orderBy
1 parent 59d8e3c commit 0dba7e8

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

LeanMapperQuery/Query.php

+8-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
* @template T of \LeanMapper\Entity
2727
*
2828
* @method $this where(string $cond, mixed ...$args)
29-
* @method $this orderBy(string $field)
29+
* @method $this orderBy(string $field, mixed ...$args)
3030
* @method $this asc(bool $asc = true)
3131
* @method $this desc(bool $desc = true)
3232
* @method $this limit(int $limit)
@@ -658,8 +658,13 @@ private function commandOrderBy($field) // @phpstan-ignore-line
658658
}
659659
}
660660
} else {
661-
$field = $this->parseStatement($field);
662-
$this->fluent->orderBy($field);
661+
$args = func_get_args();
662+
// Only first argument is parsed. Other arguments will be maintained
663+
// as parameters.
664+
$statement = &$args[0];
665+
$statement = $this->parseStatement($statement, null);
666+
$args = $this->replaceEntitiesForItsPrimaryKeyValues($args);
667+
call_user_func_array([$this->fluent, 'orderBy'], $args);
663668
}
664669
}
665670

0 commit comments

Comments
 (0)