ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ILIAS\Skill\Usage\SkillUsageDBRepository Class Reference
+ Collaboration diagram for ILIAS\Skill\Usage\SkillUsageDBRepository:

Public Member Functions

 __construct (\ilDBInterface $db=null)
 
 add (int $obj_id, int $skill_id, int $tref_id)
 
 remove (int $obj_id, int $skill_id, int $tref_id)
 
 removeFromObject (int $obj_id)
 
 removeForSkill (int $node_id, bool $is_referenece=false)
 
 getUsages (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. More...
 

Protected Attributes

ilDBInterface $db
 

Detailed Description

Definition at line 24 of file class.SkillUsageDBRepository.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Skill\Usage\SkillUsageDBRepository::__construct ( \ilDBInterface  $db = null)

Definition at line 28 of file class.SkillUsageDBRepository.php.

References ILIAS\Skill\Usage\SkillUsageDBRepository\$db, and $DIC.

30  {
31  global $DIC;
32 
33  $this->db = ($db) ?: $DIC->database();
34  }
global $DIC
Definition: feed.php:28

Member Function Documentation

◆ add()

ILIAS\Skill\Usage\SkillUsageDBRepository::add ( int  $obj_id,
int  $skill_id,
int  $tref_id 
)

Definition at line 36 of file class.SkillUsageDBRepository.php.

36  : void
37  {
38  $this->db->replace(
39  "skl_usage",
40  [
41  "obj_id" => ["integer", $obj_id],
42  "skill_id" => ["integer", $skill_id],
43  "tref_id" => ["integer", $tref_id]
44  ],
45  []
46  );
47  }

◆ getUsageInfoGeneric()

ILIAS\Skill\Usage\SkillUsageDBRepository::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.

Parameters
array{skill_idint, tref_id: int}[] $cskill_ids
Returns
array<string, array<string, array{key: string}[]>>

Definition at line 106 of file class.SkillUsageDBRepository.php.

References $q.

113  : array {
114  $usages = [];
115 
116  $w = "WHERE";
117  $q = "SELECT " . $key_field . ", " . $skill_field . ", " . $tref_field . " FROM " . $table . " ";
118  foreach ($cskill_ids as $sk) {
119  $q .= $w . " (" . $skill_field . " = " . $this->db->quote($sk["skill_id"], "integer") .
120  " AND " . $tref_field . " = " . $this->db->quote($sk["tref_id"], "integer") . ") ";
121  $w = "OR";
122  }
123  $q .= " GROUP BY " . $key_field . ", " . $skill_field . ", " . $tref_field;
124 
125  $set = $this->db->query($q);
126  while ($rec = $this->db->fetchAssoc($set)) {
127  $usages[$rec[$skill_field] . ":" . $rec[$tref_field]][$usage_type][] =
128  array("key" => $rec[$key_field]);
129  }
130 
131  return $usages;
132  }
$q
Definition: shib_logout.php:21

◆ getUsages()

ILIAS\Skill\Usage\SkillUsageDBRepository::getUsages ( int  $skill_id,
int  $tref_id 
)
Returns
int[]

Definition at line 85 of file class.SkillUsageDBRepository.php.

References ILIAS\Repository\int().

85  : array
86  {
87  $set = $this->db->query(
88  "SELECT obj_id FROM skl_usage " .
89  " WHERE skill_id = " . $this->db->quote($skill_id, "integer") .
90  " AND tref_id = " . $this->db->quote($tref_id, "integer")
91  );
92  $obj_ids = [];
93  while ($rec = $this->db->fetchAssoc($set)) {
94  $obj_ids[] = (int) $rec["obj_id"];
95  }
96 
97  return $obj_ids;
98  }
+ Here is the call graph for this function:

◆ remove()

ILIAS\Skill\Usage\SkillUsageDBRepository::remove ( int  $obj_id,
int  $skill_id,
int  $tref_id 
)

Definition at line 49 of file class.SkillUsageDBRepository.php.

49  : void
50  {
51  $this->db->manipulate(
52  "DELETE FROM skl_usage WHERE " .
53  " obj_id = " . $this->db->quote($obj_id, "integer") .
54  " AND skill_id = " . $this->db->quote($skill_id, "integer") .
55  " AND tref_id = " . $this->db->quote($tref_id, "integer")
56  );
57  }

◆ removeForSkill()

ILIAS\Skill\Usage\SkillUsageDBRepository::removeForSkill ( int  $node_id,
bool  $is_referenece = false 
)

Definition at line 67 of file class.SkillUsageDBRepository.php.

67  : void
68  {
69  if (!$is_referenece) {
70  $this->db->manipulate(
71  "DELETE FROM skl_usage WHERE " .
72  " skill_id = " . $this->db->quote($node_id, "integer")
73  );
74  } else {
75  $this->db->manipulate(
76  "DELETE FROM skl_usage WHERE " .
77  " tref_id = " . $this->db->quote($node_id, "integer")
78  );
79  }
80  }

◆ removeFromObject()

ILIAS\Skill\Usage\SkillUsageDBRepository::removeFromObject ( int  $obj_id)

Definition at line 59 of file class.SkillUsageDBRepository.php.

59  : void
60  {
61  $this->db->manipulate(
62  "DELETE FROM skl_usage WHERE " .
63  " obj_id = " . $this->db->quote($obj_id, "integer")
64  );
65  }

Field Documentation

◆ $db

ilDBInterface ILIAS\Skill\Usage\SkillUsageDBRepository::$db
protected

The documentation for this class was generated from the following file: