src/Trinity/WebshopBundle/Repository/SpecRepository.php line 25

Open in your IDE?
  1. <?php
  2. namespace App\Trinity\WebshopBundle\Repository;
  3. use Doctrine\ORM\EntityRepository;
  4. /**
  5.  * SpecRepository
  6.  */
  7. class SpecRepository extends EntityRepository
  8. {
  9.     public function countBy($Webshop$SpecGroup null){
  10.         $em $this->getEntityManager();
  11.         $query $em->createQuery(
  12.             'SELECT count(p)
  13.             FROM TrinityWebshopBundle:Spec p
  14.             ' . ($SpecGroup != null 'JOIN p.groups g WITH g.id = ' $SpecGroup->getId() . '' '') . '
  15.             WHERE p.webshop = ' $Webshop->getId() . '
  16.             '
  17.         );
  18.         return $query->getSingleScalarResult();
  19.     }
  20.     public function getBy($Webshop$SpecGroup null$offset$limit){
  21.         $em $this->getEntityManager();
  22.         $query $em->createQuery(
  23.             'SELECT p
  24.             FROM TrinityWebshopBundle:Spec p
  25.             ' . ($SpecGroup != null 'JOIN p.groups g WITH g.id = ' $SpecGroup->getId() . '' '') . '
  26.             WHERE p.webshop = ' $Webshop->getId() . '
  27.             ORDER BY p.position, p.label'
  28.         );
  29.         return $query->setFirstResult($offset)->setMaxResults($limit)->getResult();
  30.     }
  31.     public function getByGroupAndLabel($Webshop$SpecGroup$Label){
  32.         $em $this->getEntityManager();
  33.         $query $em->createQuery(
  34.             'SELECT p
  35.             FROM TrinityWebshopBundle:Spec p
  36.             ' . ($SpecGroup != null 'JOIN p.groups g WITH g.id = ' $SpecGroup->getId() . '' '') . '
  37.             WHERE p.webshop = ' $Webshop->getId() . '
  38.             AND p.label = :label
  39.             ORDER BY p.position, p.label'
  40.         )->setParameter('label'$Label);
  41.         return $query->getResult();
  42.     }
  43.     public function search($Webshop$q){
  44.         $em $this->getEntityManager();
  45.         $query $em->createQuery(
  46.             'SELECT p
  47.             FROM TrinityWebshopBundle:Spec p
  48.             WHERE p.label LIKE :q
  49.             AND p.webshop = ' $Webshop->getId() . '
  50.             ORDER BY p.position, p.label'
  51.         )
  52.         ->setParameter('q''%' $q '%');
  53.         return $query->getResult();
  54.     }
  55. }