Builder::order_by( string|null $column = null, string $order = 'ASC' )
Allow to define the clause for order by on the Query.
Contents
Parameters
- $column
-
(string|null) (Optional) The name of the column to order by, if not provided fallback to the primary key name
Default value: null
- $order
-
(string) (Optional) The type of order for the results.
Default value: 'ASC'
Return
($this)
Source
File: src/Events/Custom_Tables/V1/Models/Builder.php
public function order_by( $column = null, $order = 'ASC' ) {
if ( in_array( strtoupper( $order ), [ 'ASC', 'DESC' ], true ) ) {
$this->order = [
'column' => null === $column ? $this->model->primary_key_name() : $column,
'order' => $order,
];
}
return $this;
}
Changelog
| Version | Description |
|---|---|
| 6.0.13 | Can accept multiple order by statements. Previously order_by() would only use the last statement specified. |
| 6.0.0 | Introduced. |