Conditions | 5 |
Paths | 9 |
Total Lines | 25 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
16 | foreach ($questions as $key => $value) { |
||
17 | $where .= ' OR question_id = :question_id_'.md5($value['id']); |
||
18 | } |
||
19 | |||
20 | $stmt = $this->db->prepare('SELECT * FROM answers WHERE '.trim($where, ' OR ')); |
||
21 | foreach ($questions as $key => $value) { |
||
22 | $stmt->bindValue(':question_id_'.md5($value['id']), $value['id'], PDO::PARAM_INT); |
||
23 | } |
||
24 | |||
25 | $stmt->execute(); |
||
26 | |||
27 | $array = []; |
||
28 | foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $key => $value) { |
||
29 | $array[$value['question_id']][] = $value; |
||
30 | } |
||
31 | |||
32 | return $array; |
||
33 | } |
||
34 | |||
35 | public function getAnswersByOneQuestionId(int $questionID): array |
||
36 | { |
||
37 | $stmt = $this->db->prepare('SELECT * FROM answers WHERE question_id = :qid'); |
||
38 | $stmt->bindValue(':qid', $questionID, PDO::PARAM_INT); |
||
39 | $stmt->execute(); |
||
40 | |||
41 | return $stmt->fetchAll(PDO::FETCH_ASSOC); |
||
44 |