ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilObjUseBookDBRepository.php
Go to the documentation of this file.
1 <?php
2 
25 {
26  protected const TABLE_NAME = 'book_obj_use_book';
27  protected ilTree $tree;
28 
29  protected ilDBInterface $db;
30 
31  public function __construct(\ilDBInterface $db)
32  {
33  global $DIC;
34  $this->tree = $DIC->repositoryTree();
35  $this->db = $db;
36  }
37 
41  public function updateUsedBookingPools(
42  int $obj_id,
43  array $book_obj_ids
44  ): void {
45  $db = $this->db;
46 
47  $db->manipulateF(
48  "DELETE FROM " . self::TABLE_NAME . " WHERE " .
49  " obj_id = %s",
50  array("integer"),
51  array($obj_id)
52  );
53 
54  foreach ($book_obj_ids as $id) {
55  $db->insert(self::TABLE_NAME, array(
56  "obj_id" => array("integer", $obj_id),
57  "book_ref_id" => array("integer", $id)
58  ));
59  }
60  }
61 
65  public function getUsedBookingPools(int $obj_id, bool $include_deleted = true): array
66  {
67  $db = $this->db;
68 
69  $set = $db->queryF(
70  "SELECT * FROM " . self::TABLE_NAME . " " .
71  " WHERE obj_id = %s ",
72  array("integer"),
73  array($obj_id)
74  );
75  $book_ids = [];
76  while ($rec = $db->fetchAssoc($set)) {
77  if ($include_deleted || $this->tree->isInTree((int) $rec["book_ref_id"])) {
78  $book_ids[] = $rec["book_ref_id"];
79  }
80  }
81  return $book_ids;
82  }
83 
84  public function deleteEntriesOfBookRefId(int $ref_id) : void
85  {
86  $this->db->manipulateF("DELETE FROM " . self::TABLE_NAME . " WHERE " .
87  " book_ref_id = %s",
88  ["integer"],
89  [$ref_id]
90  );
91  }
92 }
insert(string $table_name, array $values)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
manipulateF(string $query, array $types, array $values)
fetchAssoc(ilDBStatement $statement)
global $DIC
Definition: feed.php:28
$ref_id
Definition: ltiauth.php:67
queryF(string $query, array $types, array $values)
getUsedBookingPools(int $obj_id, bool $include_deleted=true)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
updateUsedBookingPools(int $obj_id, array $book_obj_ids)