ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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
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(
87 "DELETE FROM " . self::TABLE_NAME . " WHERE " .
88 " book_ref_id = %s",
89 ["integer"],
90 [$ref_id]
91 );
92 }
93}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getUsedBookingPools(int $obj_id, bool $include_deleted=true)
updateUsedBookingPools(int $obj_id, array $book_obj_ids)
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
Interface ilDBInterface.
insert(string $table_name, array $values)
manipulateF(string $query, array $types, array $values)
fetchAssoc(ilDBStatement $statement)
queryF(string $query, array $types, array $values)
$ref_id
Definition: ltiauth.php:66
global $DIC
Definition: shib_login.php:26