Repository navigation
order
Corey Avis edited this page Sep 23, 2026
·
2 revisions
Specifies the columns/keys to be used in the ORDER BY clause of the SQL query. It accepts either a list of string arguments or a single array of keys.
📌 By default, columns passed to
order()are sorted in the database's default direction (usually ascending). To explicitly change or set the direction of specific columns, chain this method with the asc or desc modifier methods. Note that this modifier relationship does not apply to orderByValue.
order(array|string ...$columns): static
columns (array|string) : A list of column names or an array containing column names to sort the query by.
(static) : Returns the current instance to allow for method chaining.
$db->select()->order('id')->execute();
// Result: SELECT * FROM `table` ORDER BY `id`
$db->select()->order('name', 'qty')->execute();
// Result: SELECT * FROM `table` ORDER BY `name`, `qty`
$db->select()->order('name', 'qty')->desc('qty')->execute();
// Result: SELECT * FROM `table` ORDER BY `name`, `qty` DESC
- No debug errors.
orderByValue | asc | desc | compileOrder