ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilADTMultiDBBridge.php
Go to the documentation of this file.
1<?php
2
3require_once "Services/ADT/classes/Bridges/class.ilADTDBBridge.php";
4
5abstract 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?>
ADT DB bridge base class.
getElementId()
Get element id.
getPrimary()
Get primary fields.
buildPrimaryWhere()
Convert primary keys array to sql string.
getTable()
Get table name.
afterInsert()
After insert hook to enable sub-tables.
readRecord(array $a_row)
Import DB values to ADT.
afterUpdate()
After update hook to enable sub-tables.
prepareInsert(array &$a_fields)
Prepare ADT values for insert.
getSubTableName()
Build sub-table name.
readMultiRecord($a_set)
Import record-rows from sub-table.
afterDelete()
After delete hook to enable sub-tables.
prepareMultiInsert()
Build insert-fields for each "value".
global $ilDB