ILIAS  release_8 Revision v8.24
class.ilECSCourseAttribute.php
Go to the documentation of this file.
1<?php
2
18declare(strict_types=1);
19
26{
27 private int $id;
28 private int $server_id = 0;
29 private int $mid = 0;
30 private string $name = '';
31
33
37 public function __construct(int $a_id = 0)
38 {
39 global $DIC;
40
41 $this->db = $DIC->database();
42
43 $this->id = $a_id;
44
45 $this->read();
46 }
47
51 public function getId(): int
52 {
53 return $this->id;
54 }
55
56 public function setServerId(int $a_server_id): void
57 {
58 $this->server_id = $a_server_id;
59 }
60
61 public function getServerId(): int
62 {
63 return $this->server_id;
64 }
65
66 public function setMid(int $a_mid): void
67 {
68 $this->mid = $a_mid;
69 }
70
71 public function getMid(): int
72 {
73 return $this->mid;
74 }
75
76
77 public function setName(string $a_name): void
78 {
79 $this->name = $a_name;
80 }
81
85 public function getName(): string
86 {
87 return $this->name;
88 }
89
93 public function delete(): bool
94 {
95 $query = "DELETE FROM ecs_crs_mapping_atts " .
96 'WHERE id = ' . $this->db->quote($this->getId(), 'integer');
97 $this->db->manipulate($query);
98 return true;
99 }
100
104 public function save(): bool
105 {
106 $this->id = $this->db->nextId('ecs_crs_mapping_atts');
107
108 $query = 'INSERT INTO ecs_crs_mapping_atts (id,sid,mid,name) ' .
109 'VALUES ( ' .
110 $this->db->quote($this->getId(), 'integer') . ', ' .
111 $this->db->quote($this->getServerId(), 'integer') . ', ' .
112 $this->db->quote($this->getMid(), 'integer') . ', ' .
113 $this->db->quote($this->getName(), 'text') . ' ' .
114 ') ';
115 $this->db->manipulate($query);
116 return true;
117 }
118
119
120
124 protected function read(): bool
125 {
126 if (!$this->getId()) {
127 return true;
128 }
129 $query = 'SELECT * FROM ecs_crs_mapping_atts ' .
130 'WHERE id = ' . $this->db->quote($this->getId(), 'integer');
131 $res = $this->db->query($query);
132 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
133 $this->setName($row->name);
134 }
135 return true;
136 }
137}
Storage of course attributes for assignment rules.
__construct(int $a_id=0)
Constructor.
read()
read active attributes
global $DIC
Definition: feed.php:28
Interface ilDBInterface.
$res
Definition: ltiservices.php:69
$query