Completed
Push — master ( ac011d...56c397 )
by Mikołaj
03:19
created

QuestionsModel::getByQuestionId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 8
Ratio 100 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 8
loc 8
rs 9.4285
cc 1
eloc 5
nc 1
nop 1
1
<?php
2
3
namespace Egzaminer\Model;
4
5
use PDO;
6
7 View Code Duplication
class QuestionsModel extends AbstractModel
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
8
{
9
    /**
10
     * Get questions by exam ID.
11
     *
12
     * @param int $examID Exam ID
13
     *
14
     * @return array
15
     */
16
    public function getByExamId($examID)
17
    {
18
        $stmt = $this->db->prepare('SELECT * FROM questions WHERE exam_id = :exam_id');
19
        $stmt->bindValue(':exam_id', $examID, PDO::PARAM_INT);
20
        $stmt->execute();
21
22
        return $stmt->fetchAll(PDO::FETCH_ASSOC);
23
    }
24
25
    /**
26
     * Get question by ID.
27
     *
28
     * @param int $questionID Question ID
29
     *
30
     * @return array
31
     */
32
    public function getByQuestionId($questionID)
33
    {
34
        $stmt = $this->db->prepare('SELECT * FROM questions WHERE id = :id');
35
        $stmt->bindValue(':id', $questionID, PDO::PARAM_INT);
36
        $stmt->execute();
37
38
        return $stmt->fetch(PDO::FETCH_ASSOC);
39
    }
40
}
41