Learn how to find, filter, and retrieve data with IlanaORM
find()
- When you have the ID and it’s okay if the record doesn’t existfindOrFail()
- When you have the ID and the record must existfindBy()
- When searching by a specific column valuefirst()
- When you want the first record from a queryOperator | Description | Example |
---|---|---|
= | Equal (default) | where('age', 25) |
> | Greater than | where('age', '>', 18) |
>= | Greater than or equal | where('age', '>=', 21) |
< | Less than | where('price', '<', 100) |
<= | Less than or equal | where('price', '<=', 50) |
!= or <> | Not equal | where('status', '!=', 'banned') |
like | Pattern matching | where('name', 'like', '%john%') |
ilike | Case-insensitive like | where('name', 'ilike', '%JOHN%') |
?
) in raw queries to prevent SQL injection attacks. Never concatenate user input directly into SQL strings.