19 declare(strict_types=1);
37 protected \ilDBInterface
$db;
54 $create_assignments = [];
55 $update_assignments = [];
56 $delete_assignments = [];
57 $delete_full_row =
false;
58 $create_new_row =
false;
60 foreach ($row->
actions() as $action) {
61 switch ($action->action()) {
63 $create_assignments[] = $action;
64 if ($action->tag()->hasRowInTable()) {
65 $create_new_row =
true;
70 $update_assignments[] = $action;
74 $delete_assignments[] = $action;
75 if ($action->tag()->hasRowInTable()) {
76 $delete_full_row =
true;
81 if ($delete_full_row) {
82 $this->
delete($row->
table(), $row->
id());
85 if ($create_new_row) {
91 ...$create_assignments
98 ...$create_assignments,
99 ...$update_assignments,
100 ...$delete_assignments
108 int $id_from_parent_table,
111 $this->checkTable($table);
112 $table_name = $this->table($table);
113 $has_parent = $assignments[0]->
tag()->hasParent();
114 $parent = $assignments[0]->
tag()->parent();
115 $id_field = $this->IDName($table);
118 $this->db->quoteIdentifier($id_field),
130 $fields[] =
'parent_type';
132 $fields[] =
'parent_id';
135 foreach ($assignments as $assignment) {
136 $tag = $assignment->tag();
137 if ($tag->hasData() && (
$data = $assignment->value()) !==
'') {
138 $fields[] = $this->db->quoteIdentifier($tag->dataField());
143 $this->db->manipulate(
144 'INSERT INTO ' . $this->db->quoteIdentifier($table_name) .
' (' .
145 implode(
', ', $fields) .
') VALUES (' . implode(
', ', $values) .
')' 154 int $id_from_parent_table,
157 $table = $tags[0]->
table();
158 $this->checkTable($table);
160 $parent = $tags[0]->
parent();
161 $id_field = $this->IDName($table);
163 $selected_fields[] = $this->db->quoteIdentifier($id_field);
164 foreach ($tags as $tag) {
165 if ($tag->hasData()) {
166 $selected_fields[] = $this->db->quoteIdentifier($tag->dataField());
178 $order =
'ORDER BY ' . $this->db->quoteIdentifier($id_field);
180 $result = $this->db->query(
181 'SELECT ' . implode(
', ', $selected_fields) .
' FROM ' .
182 $this->db->quoteIdentifier($this->table($table)) .
' WHERE ' .
183 implode(
' AND ', $where) .
' ' . $order
186 while ($row = $this->db->fetchAssoc($result)) {
189 foreach ($row as $field => $value) {
190 if ($field === $id_field) {
194 $data[] = $this->data_row_factory->field($field, $value ??
'');
196 yield $this->data_row_factory->row(
$id, $table, ...
$data);
205 $this->checkTable($table);
206 $id_field = $this->IDName($table);
208 $updated_fields = [];
209 foreach ($assignments as $assignment) {
210 $tag = $assignment->tag();
211 if (!$tag->hasData()) {
215 $updated_fields[] = $this->db->quoteIdentifier($tag->dataField()) .
" = ''";
218 if ((
$data = $assignment->value()) !==
'') {
219 $updated_fields[] = $this->db->quoteIdentifier($tag->dataField()) .
' = ' .
224 if (empty($updated_fields)) {
228 $this->db->manipulate(
229 'UPDATE ' . $this->db->quoteIdentifier($this->table($table)) .
' SET ' .
230 implode(
', ', $updated_fields) .
' WHERE ' . $this->db->quoteIdentifier($id_field) .
235 protected function delete(
239 $this->checkTable($table);
240 $table_name = $this->table($table);
241 $id_field = $this->IDName($table);
243 $this->db->manipulate(
244 'DELETE FROM ' . $this->db->quoteIdentifier($table_name) .
' WHERE ' .
245 $this->db->quoteIdentifier($id_field) .
' = ' .
252 $rbac_id = $ressource_id->
objID();
253 $obj_id = $ressource_id->
subID();
254 $obj_type = $ressource_id->
type();
256 $query =
"DELETE FROM " . $this->db->quoteIdentifier($table) .
" " .
261 $this->db->manipulate($query);
267 $this->checkTable($table);
268 return $this->db->nextId($this->table($table));
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins