fix lists in readme
[mixstore.git] / src / Mixstore / StoreBundle / Entity / UsecaseRepository.php
CommitLineData
929ca066
BA
1<?php
2
3namespace Mixstore\StoreBundle\Entity;
4
5use Doctrine\ORM\EntityRepository;
6
7class UsecaseRepository extends EntityRepository
8{
9 function safeFindById($id)
10 {
11 if ($id > 0)
12 {
13 $qb = $this->createQueryBuilder('u');
14 $qb->where('u.id = '.$id);
15 $usecase = $qb->getQuery()->getResult()[0];
16 }
17 else
18 $usecase = new Usecase();
19
20 return $usecase;
21 }
22
23 function countByPkgId($pkgid)
24 {
25 return $this
26 ->createQueryBuilder('u')
27 ->select('COUNT(u.id) AS ucscount, AVG(u.grade) AS rating')
28 ->where('u.package = '.$pkgid)
29 ->getQuery()
30 ->getResult()[0];
31 //->getSingleScalarResult();
32 }
33}