ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilADTMultiDBBridge.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 abstract 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 }
prepareInsert(array &$a_fields)
buildPrimaryWhere()
Convert primary keys array to sql string.
getSubTableName()
Build sub-table name.
getElementId()
Get element id.
ADT DB bridge base class.
readMultiRecord(ilDBStatement $a_set)
Import record-rows from sub-table.
prepareMultiInsert()
Build insert-fields for each "value".