ILIAS  trunk Revision v11.0_alpha-1713-gd8962da2f67
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilADTMultiEnumDBBridge.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 {
23  public const TABLE_NAME = 'adv_md_values_enum';
24  public const SEPARATOR = "~|~";
25 
26  protected bool $fake_single = false;
27 
28  public function getTable(): ?string
29  {
30  return self::TABLE_NAME;
31  }
32 
33  protected function isValidADT(ilADT $a_adt): bool
34  {
35  return ($a_adt instanceof ilADTMultiEnum);
36  }
37 
38  public function setFakeSingle(bool $a_status): void
39  {
40  $this->fake_single = $a_status;
41  }
42 
43  protected function doSingleFake(): bool
44  {
45  return $this->fake_single;
46  }
47 
48  public function readRecord(array $a_row): void
49  {
50  if (isset($a_row[$this->getElementId()])) {
51  $this->getADT()->addSelection((int) $a_row[$this->getElementId()]);
52  }
53  }
54 
55  public function afterInsert(): void
56  {
57  $this->afterUpdate();
58  }
59 
60  public function afterUpdate(): void
61  {
62  $this->deleteIndices();
63  $this->insertIndices();
64  }
65 
66  public function prepareInsert(array &$a_fields): void
67  {
68  $a_fields = [];
69  }
70 
71  protected function deleteIndices(): void
72  {
73  $this->db->query(
74  'delete from ' . $this->getTable() . ' ' .
75  'where ' . $this->buildPrimaryWhere()
76  );
77  }
78 
79  protected function insertIndices(): void
80  {
81  foreach ((array) $this->getADT()->getSelections() as $index) {
82  $fields = $this->getPrimary();
83  $fields['value_index'] = [ilDBConstants::T_INTEGER, $index];
84  $num_row = $this->db->insert($this->getTable(), $fields);
85  }
86  }
87 
88  public function supportsDefaultValueColumn(): bool
89  {
90  return false;
91  }
92 }
buildPrimaryWhere()
Convert primary keys array to sql string.
getPrimary()
Get primary fields.
getElementId()
Get element id.
ADT base class.
Definition: class.ilADT.php:25
ADT DB bridge base class.