ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
SequenceDBRepository.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
24
26{
28 protected \ilDBInterface $db;
29
30 public function __construct(
33 ) {
34 $this->db = $db;
35 $this->data = $data;
36 }
37
38 protected function count(int $survey_id): int
39 {
40 $set = $this->db->queryF(
41 "SELECT count(*) cnt FROM svy_svy_qst " .
42 " WHERE survey_fi = %s ",
43 ["integer"],
44 [$survey_id]
45 );
46 if ($rec = $this->db->fetchAssoc($set)) {
47 return (int) $rec["cnt"];
48 }
49 return 0;
50 }
51
52 public function insert(int $survey_id, int $svy_question_id): int
53 {
54 $order_nr = $this->count($survey_id);
55 $next_id = $this->db->nextId('svy_svy_qst');
56 $this->db->manipulateF(
57 "INSERT INTO svy_svy_qst (survey_question_id, survey_fi," .
58 "question_fi, sequence, tstamp) VALUES (%s, %s, %s, %s, %s)",
59 array('integer', 'integer', 'integer', 'integer', 'integer'),
60 array($next_id, $survey_id, $svy_question_id, $order_nr, time())
61 );
62 return $next_id;
63 }
64}
insert(int $survey_id, int $svy_question_id)
__construct(InternalDataService $data, \ilDBInterface $db)
Interface ilDBInterface.