ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ContainerDBRepository.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
22 
23 use ilDBInterface;
24 
31 {
32  public const TABLE_NAME = 'sty_rep_container';
33 
34  protected ilDBInterface $db;
35 
36  public function __construct(ilDBInterface $db)
37  {
38  $this->db = $db;
39  }
40 
41  public function updateReuse(int $ref_id, bool $reuse): void
42  {
43  $db = $this->db;
44 
45  $db->replace(
46  self::TABLE_NAME,
47  [
48  "ref_id" => ["integer", $ref_id]
49  ],
50  [
51  "reuse" => ["integer", (int) $reuse]
52  ]
53  );
54  }
55 
56  public function readReuse(int $ref_id): bool
57  {
58  $db = $this->db;
59 
60  $set = $db->queryF(
61  "SELECT * FROM " . self::TABLE_NAME .
62  " WHERE ref_id = %s ",
63  ["integer"],
64  [$ref_id]
65  );
66  $rec = $db->fetchAssoc($set);
67 
68  return (bool) ($rec["reuse"] ?? false);
69  }
70 
75  public function filterByReuse(array $ref_ids): array
76  {
77  $db = $this->db;
78 
79  $set = $db->queryF(
80  "SELECT * FROM " . self::TABLE_NAME .
81  " WHERE reuse = %s AND " . $db->in("ref_id", $ref_ids, false, "integer"),
82  ["integer"],
83  [1]
84  );
85  $ref_ids = [];
86  while ($rec = $db->fetchAssoc($set)) {
87  $ref_ids[] = (int) $rec["ref_id"];
88  }
89  return $ref_ids;
90  }
91 }
fetchAssoc(ilDBStatement $statement)
This repo stores infos on repository objects that are using booking managers as a service (resource m...
$ref_id
Definition: ltiauth.php:67
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
queryF(string $query, array $types, array $values)
in(string $field, array $values, bool $negate=false, string $type="")
filterByReuse(array $ref_ids)
For an array of ref ids, return only the ref ids that have the reuse flag set.
replace(string $table, array $primary_keys, array $other_columns)
Replace into method.