ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 23 of file class.SkillUsageDBRepository.php.

Constructor & Destructor Documentation

◆ __construct()

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

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

29 {
30 global $DIC;
31
32 $this->db = ($db) ?: $DIC->database();
33 }
global $DIC
Definition: shib_login.php:26

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

Member Function Documentation

◆ add()

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

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

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

◆ 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 105 of file class.SkillUsageDBRepository.php.

112 : array {
113 $usages = [];
114
115 $w = "WHERE";
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") . ") ";
120 $w = "OR";
121 }
122 $q .= " GROUP BY " . $key_field . ", " . $skill_field . ", " . $tref_field;
123
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]);
128 }
129
130 return $usages;
131 }
$q
Definition: shib_logout.php:23

References $q.

◆ getUsages()

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

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

84 : array
85 {
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")
90 );
91 $obj_ids = [];
92 while ($rec = $this->db->fetchAssoc($set)) {
93 $obj_ids[] = (int) $rec["obj_id"];
94 }
95
96 return $obj_ids;
97 }

References ILIAS\Repository\int().

+ 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 48 of file class.SkillUsageDBRepository.php.

48 : void
49 {
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")
55 );
56 }

◆ removeForSkill()

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

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

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

◆ removeFromObject()

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

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

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

Field Documentation

◆ $db

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

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