ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilADTMultiDBBridge.php
Go to the documentation of this file.
1 <?php
2 
3 require_once "Services/ADT/classes/Bridges/class.ilADTDBBridge.php";
4 
5 abstract class ilADTMultiDBBridge extends ilADTDBBridge
6 {
7  // CRUD
8 
14  protected function getSubTableName()
15  {
16  // getElementId? => adv_md_values_enum_123
17  return $this->getTable() . "_" . $this->getElementId();
18  }
19 
20  public function readRecord(array $a_row)
21  {
22  global $DIC;
23 
24  $ilDB = $DIC['ilDB'];
25 
26  $sql = "SELECT " . $this->getElementId() .
27  " FROM " . $this->getSubTableName() .
28  " WHERE " . $this->buildPrimaryWhere();
29  $set = $ilDB->query($sql);
30 
31  $this->readMultiRecord($set);
32  }
33 
39  abstract protected function readMultiRecord($a_set);
40 
41  public function prepareInsert(array &$a_fields)
42  {
43  // see afterUpdate()
44  }
45 
46  public function afterInsert()
47  {
48  $this->afterUpdate();
49  }
50 
51  public function afterUpdate()
52  {
53  global $DIC;
54 
55  $ilDB = $DIC['ilDB'];
56 
57  // :TODO: build diff, save difference
58  // is this in use? Cannot
59  /*
60  $ilDB->manipulate("DELETE FROM " . $this->getSubTableName() .
61  " WHERE " . $this->buildPrimaryWhere());
62 
63  foreach ($this->prepareMultiInsert() as $sub_items) {
64  $fields = array_merge($this->getPrimary(), $sub_items);
65 
66  $ilDB->insert($this->getSubTableName(), $fields);
67  }
68  */
69  }
70 
76  abstract protected function prepareMultiInsert();
77 
78  public function afterDelete()
79  {
80  global $DIC;
81 
82  $ilDB = $DIC['ilDB'];
83 
84  // is this in use? Cannot
85  /*
86  $ilDB->manipulate("DELETE FROM " . $this->getSubTableName() .
87  " WHERE " . $this->buildPrimaryWhere());
88  */
89  }
90 }
prepareInsert(array &$a_fields)
buildPrimaryWhere()
Convert primary keys array to sql string.
getSubTableName()
Build sub-table name.
getTable()
Get table name.
getElementId()
Get element id.
ADT DB bridge base class.
global $DIC
Definition: goto.php:24
prepareMultiInsert()
Build insert-fields for each "value".
global $ilDB
readMultiRecord($a_set)
Import record-rows from sub-table.