I am doing this in my controller
$C100 = $em->getRepository('AcmeJunkieBundle:Junk')->findBy(array('type'=> 'C100'),array('day' => 'ASC'));
$C200 = $em->getRepository('AcmeJunkieBundle:Junk')->findBy(array('type'=> 'C200'),array('day' => 'ASC'));
$C300 = $em->getRepository('AcmeJunkieBundle:Junk')->findBy(array('type'=> 'C300'),array('day' => 'ASC'));
‘type’ is just string field
IS there any way to do that in single query and then do something like
$C100 = $result['C100']
$C200 = $result['C200']
$C300 = $result['C200']
We need to know about your
Junkentity: istypejust a string field?Anyway you may write your own repository methods in associated repository class: your
Junkclass source will be something like this I assume:src/Acme/JunkieBundle/Entity/Junk.php
Make sure you have an annotation with the repository class name, then write up that class – the one being fetched by
$C100 = $em->getRepository()method in the controller.src/Acme/JunkieBundle/Repository/JunkRepository.php
Now you may call
in your controller.
Be sure to check Doctrine docs.