Skip to content

Commit 3d0ed8e

Browse files
authored
Update optional-conditions.md
1 parent 9b4f483 commit 3d0ed8e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

doc/optional-conditions.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,17 @@ $filter = [
1111
],
1212
];
1313

14+
$orderBy = [
15+
['date', 'DESC'], // Define the Sort-Order as a Multi-Value-Field
16+
['name' => 'ASC'], // ... or define the Sort-Order as a Key-Value-Field
17+
];
18+
1419
$query = $db
1520
->from('t', 'test')
1621
->where(new DBExprFilter('t.name = ?', $filter, 'name'))
1722
->where(new DBExprFilter('t.date >= ?', $filter, 'date.start')) // Key in dot-notation
1823
->where(new DBExprFilter('t.date <= ?', $filter, ['date', 'end'])) // Key in array-notation
24+
->orderBy(new DBExprOrderBySpec(['name', 'date' => 'DATE(t.date)'], $orderBy))
1925
```
2026

2127
You can also define validation rules to only match certain data in `$filter`.

0 commit comments

Comments
 (0)