ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ObjectDBRepository.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
24
31{
32 public const DATA_TABLE_NAME = 'style_data';
33
34 protected ilDBInterface $db;
35
36 public function __construct(ilDBInterface $db)
37 {
38 $this->db = $db;
39 }
40
47 public function getOwnedStyles(array $owner_obj_ids): array
48 {
49 $db = $this->db;
50
51 $set = $db->queryF(
52 "SELECT * FROM style_usage su JOIN style_data sd " .
53 " ON (su.style_id = sd.id AND su.obj_id = sd.owner_obj) " .
54 " WHERE " . $db->in("su.obj_id", $owner_obj_ids, false, "integer"),
55 [],
56 []
57 );
58
59 $owned = [];
60 while ($rec = $db->fetchAssoc($set)) {
61 $owned[(int) $rec["owner_obj"]] = (int) $rec["style_id"];
62 }
63 return $owned;
64 }
65
66 // is a style owned by an object?
67 public function isOwned(int $obj_id, int $style_id): bool
68 {
69 $db = $this->db;
70
71 $set = $db->queryF(
72 "SELECT * FROM style_data " .
73 " WHERE id = %s AND owner_obj = %s",
74 ["integer", "integer"],
75 [$style_id, $obj_id]
76 );
77
78 if ($db->fetchAssoc($set)) {
79 return true;
80 }
81 return false;
82 }
83
84
85 public function countOverallOwned(): int
86 {
87 $db = $this->db;
88 $set = $db->queryF(
89 "SELECT count(*) cnt FROM style_data " .
90 " WHERE owner_obj > %s",
91 ["integer"],
92 [0]
93 );
94
95 if ($rec = $db->fetchAssoc($set)) {
96 return (int) $rec["cnt"];
97 }
98 return 0;
99 }
100
101 public function countObjSelected(int $style_id): int
102 {
103 $db = $this->db;
104 $set = $db->queryF(
105 "SELECT count(*) cnt FROM style_usage " .
106 " WHERE style_id = %s",
107 ["integer"],
108 [$style_id]
109 );
110
111 if ($rec = $db->fetchAssoc($set)) {
112 return (int) $rec["cnt"];
113 }
114 return 0;
115 }
116
117}
This repo stores infos on repository objects that are using booking managers as a service (resource m...
getOwnedStyles(array $owner_obj_ids)
For an array of object IDs (objects using styles) get back their owned styles (if any),...
Interface ilDBInterface.
fetchAssoc(ilDBStatement $statement)
queryF(string $query, array $types, array $values)
in(string $field, array $values, bool $negate=false, string $type="")