ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilADTMultiEnumDBBridge.php
Go to the documentation of this file.
1 <?php
2 
3 require_once "Services/ADT/classes/Bridges/class.ilADTMultiDBBridge.php";
4 
6 {
7  const TABLE_NAME = 'adv_md_values_enum';
8 
12  protected $db;
13 
14  protected $fake_single;
15 
16  const SEPARATOR = "~|~";
17 
18  public function __construct(ilADT $a_adt)
19  {
20  global $DIC;
21 
22  $this->db = $DIC->database();
23  parent::__construct($a_adt);
24  }
25 
26  public function getTable() : string
27  {
28  return self::TABLE_NAME;
29  }
30 
31  protected function isValidADT(ilADT $a_adt)
32  {
33  return ($a_adt instanceof ilADTMultiEnum);
34  }
35 
36  public function setFakeSingle($a_status)
37  {
38  $this->fake_single = (bool) $a_status;
39  }
40 
41  protected function doSingleFake()
42  {
43  return $this->fake_single;
44  }
45 
46  public function readRecord(array $a_row)
47  {
48  if (isset($a_row[$this->getElementId()])) {
49  $this->getADT()->addSelection($a_row[$this->getElementId()]);
50  }
51  }
52 
53  public function afterInsert()
54  {
55  return $this->afterUpdate();
56  }
57 
58  public function afterUpdate()
59  {
60  $this->deleteIndices();
61  $this->insertIndices();
62  }
63 
64  public function prepareInsert(array &$a_fields)
65  {
66  $a_fields = [];
67  }
68 
69  protected function deleteIndices()
70  {
71  $this->db->query(
72  'delete from ' . $this->getTable() . ' ' .
73  'where ' . $this->buildPrimaryWhere()
74  );
75  }
76 
77  protected function insertIndices()
78  {
79  foreach ($this->getADT()->getSelections() as $index)
80  {
81  $fields = $this->getPrimary();
82  $fields['value_index'] = [ilDBConstants::T_INTEGER, $index];
83  $num_row = $this->db->insert($this->getTable(), $fields);
84  ilLoggerFactory::getLogger('amet')->dump($num_row);
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:11
$index
Definition: metadata.php:128
ADT DB bridge base class.
global $DIC
Definition: goto.php:24
__construct(Container $dic, ilPlugin $plugin)
static getLogger($a_component_id)
Get component logger.