3 namespace Mixstore\StoreBundle\Entity
;
5 use Doctrine\ORM\EntityRepository
;
7 class PackageRepository
extends EntityRepository
9 function safeFindById($id)
13 $qb = $this->createQueryBuilder('p');
14 $qb->where('p.id = '.$id);
15 $package = $qb->getQuery()->getResult()[0];
18 $package = new Package();
23 function getAllNames()
26 ->createQueryBuilder('p')
27 ->select('p.id, p.name')
32 function getBannersUrls()
35 ->createQueryBuilder('p')
36 ->select('p.id, p.bannerpath')
37 ->where('p.bannerpath IS NOT NULL')
41 for ($i=0; $i<count($bannersUrls); $i++
)
42 $result[$bannersUrls[$i]['id']] = $bannersUrls[$i]['bannerpath'];
46 function getLastNews()
49 ->createQueryBuilder('p')
50 ->select('p.id, p.name, p.created')
51 ->orderBy('p.created', 'DESC')
52 ->setMaxResults(3) //currently hard-coded