ILIAS  release_8 Revision v8.24
class.ilADTMultiDBBridge.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
5abstract class ilADTMultiDBBridge extends ilADTDBBridge
6{
10 protected function getSubTableName(): string
11 {
12 // getElementId? => adv_md_values_enum_123
13 return $this->getTable() . "_" . $this->getElementId();
14 }
15
16 public function readRecord(array $a_row): void
17 {
18 $sql = "SELECT " . $this->getElementId() .
19 " FROM " . $this->getSubTableName() .
20 " WHERE " . $this->buildPrimaryWhere();
21 $set = $this->db->query($sql);
22 $this->readMultiRecord($set);
23 }
24
29 abstract protected function readMultiRecord(ilDBStatement $a_set): void;
30
31 public function prepareInsert(array &$a_fields): void
32 {
33 // see afterUpdate()
34 }
35
36 public function afterInsert(): void
37 {
38 $this->afterUpdate();
39 }
40
41 public function afterUpdate(): void
42 {
43 // :TODO: build diff, save difference
44 // is this in use? Cannot
45 /*
46 $ilDB->manipulate("DELETE FROM " . $this->getSubTableName() .
47 " WHERE " . $this->buildPrimaryWhere());
48
49 foreach ($this->prepareMultiInsert() as $sub_items) {
50 $fields = array_merge($this->getPrimary(), $sub_items);
51
52 $ilDB->insert($this->getSubTableName(), $fields);
53 }
54 */
55 }
56
60 abstract protected function prepareMultiInsert(): array;
61
62 public function afterDelete(): void
63 {
64 // is this in use? Cannot
65 /*
66 $ilDB->manipulate("DELETE FROM " . $this->getSubTableName() .
67 " WHERE " . $this->buildPrimaryWhere());
68 */
69 }
70}
ADT DB bridge base class.
getElementId()
Get element id.
buildPrimaryWhere()
Convert primary keys array to sql string.
afterInsert()
After insert hook to enable sub-tables.
readRecord(array $a_row)
Import DB values to ADT.
readMultiRecord(ilDBStatement $a_set)
Import record-rows from sub-table.
afterUpdate()
After update hook to enable sub-tables.
prepareInsert(array &$a_fields)
Prepare ADT values for insert.
getSubTableName()
Build sub-table name.
afterDelete()
After delete hook to enable sub-tables.
prepareMultiInsert()
Build insert-fields for each "value".
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...