Allow EntityRepository::FindBy to accept a Criteria object or array. #6136

Closed
opened 2026-01-22 15:27:27 +01:00 by admin · 5 comments
Owner

Originally created by @PyRowMan on GitHub (Dec 14, 2018).

Feature Request

In order to do advanced where clauses select (greaterThan, lesserThan, equals...).

Would it be possible to allow the method EntityRepository::FindBy to take a Criteria object OR an array of params.

It would be easier to perform some advanced where clauses.

Q A
New Feature yes
RFC yes
BC Break no

Summary

Since I don't usually work inside the doctrine project, I don't really know what are the impacts of this request. I saw that there is one or two interfaces to modify, and some recovering parameter way, but this is only for the MySQL driver.

Originally created by @PyRowMan on GitHub (Dec 14, 2018). ### Feature Request In order to do advanced where clauses select (greaterThan, lesserThan, equals...). Would it be possible to allow the method EntityRepository::FindBy to take a Criteria object OR an array of params. It would be easier to perform some advanced where clauses. | Q | A |------------ | ------ | New Feature | yes | RFC | yes | BC Break | no #### Summary Since I don't usually work inside the doctrine project, I don't really know what are the impacts of this request. I saw that there is one or two interfaces to modify, and some recovering parameter way, but this is only for the MySQL driver.
admin added the Improvement label 2026-01-22 15:27:27 +01:00
admin closed this issue 2026-01-22 15:27:27 +01:00
Author
Owner

@Ocramius commented on GitHub (Dec 14, 2018):

I'd rather say that a separate findByCriteria() would be preferable, over having a union type.

@Ocramius commented on GitHub (Dec 14, 2018): I'd rather say that a separate `findByCriteria()` would be preferable, over having a union type.
Author
Owner

@dlgoodchild commented on GitHub (Aug 12, 2020):

I've just come across this from wondering how to specify operators for the findBy criteria array.

I think having a findByCriteria and findOneByCriteria would be a great addition here.

@dlgoodchild commented on GitHub (Aug 12, 2020): I've just come across this from wondering how to specify operators for the `findBy` criteria array. I think having a `findByCriteria` and `findOneByCriteria` would be a great addition here.
Author
Owner

@Ocramius commented on GitHub (Aug 12, 2020):

Are you perhaps looking for https://github.com/doctrine/orm/blob/v2.7.3/lib/Doctrine/ORM/EntityRepository.php#L281?

@Ocramius commented on GitHub (Aug 12, 2020): Are you perhaps looking for https://github.com/doctrine/orm/blob/v2.7.3/lib/Doctrine/ORM/EntityRepository.php#L281?
Author
Owner

@dlgoodchild commented on GitHub (Aug 12, 2020):

Mmm that seems to be quite different to the find... methods and it recieves only a single Criteria object (and returns a Collection), seems a bit inconsistent and I can't find the documentation covering matching.

@dlgoodchild commented on GitHub (Aug 12, 2020): Mmm that seems to be quite different to the `find...` methods and it recieves only a single Criteria object (and returns a Collection), seems a bit inconsistent and I can't find the documentation covering `matching`.
Author
Owner

@beberlei commented on GitHub (Dec 6, 2020):

Yes EntityRepository::matching is the solution here. Different API is needed so you can support lazy and subfiltering.

@beberlei commented on GitHub (Dec 6, 2020): Yes `EntityRepository::matching` is the solution here. Different API is needed so you can support lazy and subfiltering.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6136