ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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  return $this->getTable() . "_" . $this->getElementId();
17  }
18 
19  public function readRecord(array $a_row)
20  {
21  global $ilDB;
22 
23  $sql = "SELECT " . $this->getElementId() .
24  " FROM " . $this->getSubTableName() .
25  " WHERE " . $this->buildPrimaryWhere();
26  $set = $ilDB->query($sql);
27 
28  $this->readMultiRecord($set);
29  }
30 
36  abstract protected function readMultiRecord($a_set);
37 
38  public function prepareInsert(array &$a_fields)
39  {
40  // see afterUpdate()
41  }
42 
43  public function afterInsert()
44  {
45  $this->afterUpdate();
46  }
47 
48  public function afterUpdate()
49  {
50  global $ilDB;
51 
52  // :TODO: build diff, save difference
53 
54  $ilDB->manipulate("DELETE FROM " . $this->getSubTableName() .
55  " WHERE " . $this->buildPrimaryWhere());
56 
57  foreach ($this->prepareMultiInsert() as $sub_items) {
58  $fields = array_merge($this->getPrimary(), $sub_items);
59 
60  $ilDB->insert($this->getSubTableName(), $fields);
61  }
62  }
63 
69  abstract protected function prepareMultiInsert();
70 
71  public function afterDelete()
72  {
73  global $ilDB;
74 
75  $ilDB->manipulate("DELETE FROM " . $this->getSubTableName() .
76  " WHERE " . $this->buildPrimaryWhere());
77  }
78 }
prepareInsert(array &$a_fields)
buildPrimaryWhere()
Convert primary keys array to sql string.
getSubTableName()
Build sub-table name.
getTable()
Get table name.
getPrimary()
Get primary fields.
getElementId()
Get element id.
ADT DB bridge base class.
prepareMultiInsert()
Build insert-fields for each "value".
Create styles array
The data for the language used.
global $ilDB
readMultiRecord($a_set)
Import record-rows from sub-table.