Skip to content

Commit

Permalink
Merge pull request #270 from klimesf/patch-1
Browse files Browse the repository at this point in the history
Added more examples of EntityRepository::findBy() operators
  • Loading branch information
fprochazka authored Jul 8, 2016
2 parents e925faa + 912104c commit 13716b1
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions docs/en/repository.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,27 @@ $commentsRepository->findBy(['article.title' => $title]);
```

And you can even use other operation than only equals!
Those operators are:
- `!=` or `not`
- `<`
- `<=`
- `>`
- `>=`

```php
$commentsRepository->findBy(['article.date >=' => new \DateTime('-1 day')]);
$commentsRepository->findBy(['article.date >' => new \DateTime('-1 day')]);
$commentsRepository->findBy(['article.date <' => new \DateTime('-1 day')]);
$commentsRepository->findBy(['article.date <=' => new \DateTime('-1 day')]);
$commentsRepository->findBy(['article.date !=' => new \DateTime('-1 day')]);
```

You can also use array or `NULL` as value of the property to create SQL `IN` or `IS` command
```php
$commentsRepository->findBy(['article.id =' => [1, 2, 3]]); // article.id IN
$commentsRepository->findBy(['article.id not' => [1, 2, 3]]); // article.id NOT IN
$commentsRepository->findBy(['article.id' => NULL]); // article.id IS NULL
$commentsRepository->findBy(['article.id not' => NULL]); // article.id IS NOT NULL
```

You can even order by relations
Expand Down

0 comments on commit 13716b1

Please sign in to comment.