ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ContainerDBRepository.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
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}
This repo stores infos on repository objects that are using booking managers as a service (resource m...
filterByReuse(array $ref_ids)
For an array of ref ids, return only the ref ids that have the reuse flag set.
Interface ilDBInterface.
replace(string $table, array $primary_keys, array $other_columns)
Replace into method.
fetchAssoc(ilDBStatement $statement)
queryF(string $query, array $types, array $values)
in(string $field, array $values, bool $negate=false, string $type="")
$ref_id
Definition: ltiauth.php:66