ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilADTMultiDBBridge.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21abstract class ilADTMultiDBBridge extends ilADTDBBridge
22{
26 protected function getSubTableName(): string
27 {
28 // getElementId? => adv_md_values_enum_123
29 return $this->getTable() . "_" . $this->getElementId();
30 }
31
32 public function readRecord(array $a_row): void
33 {
34 $sql = "SELECT " . $this->getElementId() .
35 " FROM " . $this->getSubTableName() .
36 " WHERE " . $this->buildPrimaryWhere();
37 $set = $this->db->query($sql);
38 $this->readMultiRecord($set);
39 }
40
45 abstract protected function readMultiRecord(ilDBStatement $a_set): void;
46
47 public function prepareInsert(array &$a_fields): void
48 {
49 // see afterUpdate()
50 }
51
52 public function afterInsert(): void
53 {
54 $this->afterUpdate();
55 }
56
57 public function afterUpdate(): void
58 {
59 // :TODO: build diff, save difference
60 // is this in use? Cannot
61 /*
62 $ilDB->manipulate("DELETE FROM " . $this->getSubTableName() .
63 " WHERE " . $this->buildPrimaryWhere());
64
65 foreach ($this->prepareMultiInsert() as $sub_items) {
66 $fields = array_merge($this->getPrimary(), $sub_items);
67
68 $ilDB->insert($this->getSubTableName(), $fields);
69 }
70 */
71 }
72
76 abstract protected function prepareMultiInsert(): array;
77
78 public function afterDelete(): void
79 {
80 // is this in use? Cannot
81 /*
82 $ilDB->manipulate("DELETE FROM " . $this->getSubTableName() .
83 " WHERE " . $this->buildPrimaryWhere());
84 */
85 }
86}
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".
Interface ilDBStatement.