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