ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.FlashcardBoxDBRepository.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
21 namespace ILIAS\Glossary\Flashcard;
22 
27 {
28  protected \ilDBInterface $db;
29 
30  public function __construct(
31  \ilDBInterface $db
32  ) {
33  $this->db = $db;
34  }
35 
36  public function getEntry(
37  int $box_nr,
38  int $user_id,
39  int $glo_id
40  ): array {
41  $set = $this->db->queryF(
42  "SELECT * FROM glo_flashcard_box " .
43  " WHERE box_nr = %s AND user_id = %s AND glo_id = %s ",
44  ["integer", "integer", "integer"],
45  [$box_nr, $user_id, $glo_id]
46  );
47 
48  $entry = [];
49  if ($rec = $this->db->fetchAssoc($set)) {
50  $entry = [
51  "box_nr" => $rec["box_nr"],
52  "user_id" => $rec["user_id"],
53  "glo_id" => $rec["glo_id"],
54  "last_access" => $rec["last_access"],
55  ];
56  }
57 
58  return $entry;
59  }
60 
61  public function createOrUpdateEntry(
62  int $box_nr,
63  int $user_id,
64  int $glo_id,
65  string $date
66  ): void {
67  $this->db->replace(
68  "glo_flashcard_box",
69  [
70  "box_nr" => ["integer", $box_nr],
71  "user_id" => ["integer", $user_id],
72  "glo_id" => ["integer", $glo_id]
73  ],
74  [
75  "last_access" => ["date", $date]
76  ]
77  );
78  }
79 
80  public function deleteEntries(
81  int $glo_id,
82  int $user_id
83  ): void {
84  $q = "DELETE FROM glo_flashcard_box " .
85  " WHERE glo_id = " . $this->db->quote($glo_id, "integer") .
86  " AND user_id = " . $this->db->quote($user_id, "integer");
87  $this->db->manipulate($q);
88  }
89 
90  public function deleteAllUserEntries(
91  int $user_id
92  ): void {
93  $q = "DELETE FROM glo_flashcard_box " .
94  " WHERE user_id = " . $this->db->quote($user_id, "integer");
95  $this->db->manipulate($q);
96  }
97 
98  public function deleteAllGlossaryEntries(
99  int $glo_id
100  ): void {
101  $q = "DELETE FROM glo_flashcard_box " .
102  " WHERE glo_id = " . $this->db->quote($glo_id, "integer");
103  $this->db->manipulate($q);
104  }
105 }
createOrUpdateEntry(int $box_nr, int $user_id, int $glo_id, string $date)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$q
Definition: shib_logout.php:21