19 declare(strict_types=1);
25 protected \ilDBInterface
$db;
32 $this->db = (
$db) ?: $DIC->database();
35 public function add(
int $obj_id,
int $skill_id,
int $tref_id): void
40 "obj_id" => [
"integer", $obj_id],
41 "skill_id" => [
"integer", $skill_id],
42 "tref_id" => [
"integer", $tref_id]
48 public function remove(
int $obj_id,
int $skill_id,
int $tref_id):
void 50 $this->db->manipulate(
51 "DELETE FROM skl_usage WHERE " .
52 " obj_id = " . $this->db->quote($obj_id,
"integer") .
53 " AND skill_id = " . $this->db->quote($skill_id,
"integer") .
54 " AND tref_id = " . $this->db->quote($tref_id,
"integer")
60 $this->db->manipulate(
61 "DELETE FROM skl_usage WHERE " .
62 " obj_id = " . $this->db->quote($obj_id,
"integer")
66 public function removeForSkill(
int $node_id,
bool $is_referenece =
false): void
68 if (!$is_referenece) {
69 $this->db->manipulate(
70 "DELETE FROM skl_usage WHERE " .
71 " skill_id = " . $this->db->quote($node_id,
"integer")
74 $this->db->manipulate(
75 "DELETE FROM skl_usage WHERE " .
76 " tref_id = " . $this->db->quote($node_id,
"integer")
84 public function getUsages(
int $skill_id,
int $tref_id): array
86 $set = $this->db->query(
87 "SELECT obj_id FROM skl_usage " .
88 " WHERE skill_id = " . $this->db->quote($skill_id,
"integer") .
89 " AND tref_id = " . $this->db->quote($tref_id,
"integer")
92 while ($rec = $this->db->fetchAssoc($set)) {
93 $obj_ids[] = (
int) $rec[
"obj_id"];
110 string $skill_field =
"skill_id",
111 string $tref_field =
"tref_id" 116 $q =
"SELECT " . $key_field .
", " . $skill_field .
", " . $tref_field .
" FROM " . $table .
" ";
117 foreach ($cskill_ids as $sk) {
118 $q .= $w .
" (" . $skill_field .
" = " . $this->db->quote($sk[
"skill_id"],
"integer") .
119 " AND " . $tref_field .
" = " . $this->db->quote($sk[
"tref_id"],
"integer") .
") ";
122 $q .=
" GROUP BY " . $key_field .
", " . $skill_field .
", " . $tref_field;
124 $set = $this->db->query(
$q);
125 while ($rec = $this->db->fetchAssoc($set)) {
126 $usages[$rec[$skill_field] .
":" . $rec[$tref_field]][$usage_type][] =
127 array(
"key" => $rec[$key_field]);
getUsages(int $skill_id, int $tref_id)
__construct(?\ilDBInterface $db=null)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
removeFromObject(int $obj_id)
add(int $obj_id, int $skill_id, int $tref_id)
getUsageInfoGeneric(array $cskill_ids, string $usage_type, string $table, string $key_field, string $skill_field="skill_id", string $tref_field="tref_id")
Get standard usage query.
removeForSkill(int $node_id, bool $is_referenece=false)