Completed
Push — master ( cf4f4c...f3c478 )
by Julito
36:36
created

CExerciseCategoryRepository::getCourseCount()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
nc 1
nop 1
dl 0
loc 8
rs 10
c 1
b 0
f 0
1
<?php
2
/* For licensing terms, see /license.txt */
3
4
namespace Chamilo\CourseBundle\Repository;
5
6
use Chamilo\CoreBundle\Repository\ResourceRepository;
7
8
/**
9
 * Class CExerciseCategoryRepository.
10
 */
11
final class CExerciseCategoryRepository extends ResourceRepository
12
{
13
    /**
14
     * Gets the number of values stored in the table (all fields together)
15
     * for this type of resource.
16
     *
17
     * @param int $courseId
18
     *
19
     * @return int Number of rows in the table
20
     */
21
    public function getCourseCount($courseId)
22
    {
23
        $query = $this->getRepository()->createQueryBuilder('e');
24
        $query->select('count(e.id)');
25
        $query->where('e.cId = :cId');
26
        $query->setParameter('cId', $courseId);
27
28
        return $query->getQuery()->getSingleScalarResult();
29
    }
30
31
    /**
32
     * @param int $courseId
33
     *
34
     * @return array
35
     */
36
    public function getCategories($courseId)
37
    {
38
        $query = $this->getRepository()->createQueryBuilder('e');
39
        $query->where('e.cId = :cId');
40
        $query->setParameter('cId', $courseId);
41
        $query->orderBy('e.position');
42
43
        return $query->getQuery()->getResult();
44
    }
45
}
46