findAll with conditions in symfony2

Michael picture Michael · Feb 7, 2013 · Viewed 11.2k times · Source

is there a way to use the findAll() function with conditions?

I want to do something like

->findAll('active'=1);

I know that i can write custom repository classes but just for a simple "where-condition" I thought there is an easier way.

Answer

moonwave99 picture moonwave99 · Feb 7, 2013

You can use findBy:

$objects = $yourRepo -> findBy(array('key' => $value ));