ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups 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  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  {
59  $fields = array_merge($this->getPrimary(), $sub_items);
60 
61  $ilDB->insert($this->getSubTableName(), $fields);
62  }
63  }
64 
70  abstract protected function prepareMultiInsert();
71 
72  public function afterDelete()
73  {
74  global $ilDB;
75 
76  $ilDB->manipulate("DELETE FROM ".$this->getSubTableName().
77  " WHERE ".$this->buildPrimaryWhere());
78  }
79 }
80 
81 ?>