ILIAS  trunk Revision v12.0_alpha-16-g3e876e53c80
UserFinishedDBRepository.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
24
26{
27 public function __construct(
28 protected ilDBInterface $db
29 ) {
30 }
31
32 public function setFinished(int $tour_id, int $user_id): void
33 {
34 $this->db->replace("help_gt_user_finished", [
35 "tour_id" => ["integer", $tour_id],
36 "user_id" => ["integer", $user_id],
37 ], []);
38 }
39
40 public function hasFinished(int $tour_id, int $user_id): bool
41 {
42 $set = $this->db->queryF(
43 "SELECT * FROM help_gt_user_finished " .
44 " WHERE tour_id = %s AND user_id = %s",
45 ["integer", "integer"],
46 [$tour_id, $user_id]
47 );
48 if ($rec = $this->db->fetchAssoc($set)) {
49 return true;
50 }
51 return false;
52 }
53
54 public function resetTour(int $tour_id): void
55 {
56 $this->db->manipulateF(
57 "DELETE FROM help_gt_user_finished WHERE " .
58 "tour_id = %s",
59 ["integer"],
60 [$tour_id]
61 );
62 }
63}
Interface ilDBInterface.