ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilADTMultiDBBridge Class Reference
+ Inheritance diagram for ilADTMultiDBBridge:
+ Collaboration diagram for ilADTMultiDBBridge:

Public Member Functions

 readRecord (array $a_row)
 Import DB values to ADT. More...
 
 prepareInsert (array &$a_fields)
 Prepare ADT values for insert. More...
 
 afterInsert ()
 After insert hook to enable sub-tables. More...
 
 afterUpdate ()
 After update hook to enable sub-tables. More...
 
 afterDelete ()
 After delete hook to enable sub-tables. More...
 
- Public Member Functions inherited from ilADTDBBridge
 __construct (ilADT $a_adt)
 Constructor. More...
 
 getADT ()
 Get ADT. More...
 
 setTable ($a_table)
 Set table name. More...
 
 getTable ()
 Get table name. More...
 
 setElementId ($a_value)
 Set element id (aka DB column[s] [prefix]) More...
 
 getElementId ()
 Get element id. More...
 
 setPrimary (array $a_value)
 Set primary fields (in MDB2 format) More...
 
 getPrimary ()
 Get primary fields. More...
 
 buildPrimaryWhere ()
 Convert primary keys array to sql string. More...
 
 readRecord (array $a_row)
 Import DB values to ADT. More...
 
 prepareInsert (array &$a_fields)
 Prepare ADT values for insert. More...
 
 afterInsert ()
 After insert hook to enable sub-tables. More...
 
 prepareUpdate (array &$a_fields)
 Prepare ADT values for update. More...
 
 afterUpdate ()
 After update hook to enable sub-tables. More...
 
 afterDelete ()
 After delete hook to enable sub-tables. More...
 

Protected Member Functions

 getSubTableName ()
 Build sub-table name. More...
 
 readMultiRecord ($a_set)
 Import record-rows from sub-table. More...
 
 prepareMultiInsert ()
 Build insert-fields for each "value". More...
 
- Protected Member Functions inherited from ilADTDBBridge
 isValidADT (ilADT $a_adt)
 Check if given ADT is valid. More...
 
 setADT (ilADT $a_adt)
 Set ADT. More...
 

Additional Inherited Members

- Protected Attributes inherited from ilADTDBBridge
 $adt
 
 $table
 
 $id
 
 $primary = []
 

Detailed Description

Definition at line 5 of file class.ilADTMultiDBBridge.php.

Member Function Documentation

◆ afterDelete()

ilADTMultiDBBridge::afterDelete ( )

After delete hook to enable sub-tables.

Reimplemented from ilADTDBBridge.

Definition at line 75 of file class.ilADTMultiDBBridge.php.

76 {
77 global $DIC;
78
79 $ilDB = $DIC['ilDB'];
80
81 $ilDB->manipulate("DELETE FROM " . $this->getSubTableName() .
82 " WHERE " . $this->buildPrimaryWhere());
83 }
buildPrimaryWhere()
Convert primary keys array to sql string.
getSubTableName()
Build sub-table name.
global $ilDB
$DIC
Definition: xapitoken.php:46

References $DIC, $ilDB, ilADTDBBridge\buildPrimaryWhere(), and getSubTableName().

+ Here is the call graph for this function:

◆ afterInsert()

ilADTMultiDBBridge::afterInsert ( )

After insert hook to enable sub-tables.

Reimplemented from ilADTDBBridge.

Definition at line 45 of file class.ilADTMultiDBBridge.php.

46 {
47 $this->afterUpdate();
48 }
afterUpdate()
After update hook to enable sub-tables.

References afterUpdate().

+ Here is the call graph for this function:

◆ afterUpdate()

ilADTMultiDBBridge::afterUpdate ( )

After update hook to enable sub-tables.

Reimplemented from ilADTDBBridge.

Definition at line 50 of file class.ilADTMultiDBBridge.php.

51 {
52 global $DIC;
53
54 $ilDB = $DIC['ilDB'];
55
56 // :TODO: build diff, save difference
57
58 $ilDB->manipulate("DELETE FROM " . $this->getSubTableName() .
59 " WHERE " . $this->buildPrimaryWhere());
60
61 foreach ($this->prepareMultiInsert() as $sub_items) {
62 $fields = array_merge($this->getPrimary(), $sub_items);
63
64 $ilDB->insert($this->getSubTableName(), $fields);
65 }
66 }
getPrimary()
Get primary fields.
prepareMultiInsert()
Build insert-fields for each "value".

References $DIC, $ilDB, ilADTDBBridge\buildPrimaryWhere(), ilADTDBBridge\getPrimary(), getSubTableName(), and prepareMultiInsert().

Referenced by afterInsert().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSubTableName()

ilADTMultiDBBridge::getSubTableName ( )
protected

Build sub-table name.

Returns
string

Definition at line 14 of file class.ilADTMultiDBBridge.php.

15 {
16 return $this->getTable() . "_" . $this->getElementId();
17 }
getElementId()
Get element id.
getTable()
Get table name.

References ilADTDBBridge\getElementId(), and ilADTDBBridge\getTable().

Referenced by afterDelete(), afterUpdate(), readRecord(), and ilADTMultiEnumDBBridge\readRecord().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ prepareInsert()

ilADTMultiDBBridge::prepareInsert ( array &  $a_fields)

Prepare ADT values for insert.

Parameters
array&$a_fields

Reimplemented from ilADTDBBridge.

Reimplemented in ilADTMultiEnumDBBridge.

Definition at line 40 of file class.ilADTMultiDBBridge.php.

41 {
42 // see afterUpdate()
43 }

◆ prepareMultiInsert()

ilADTMultiDBBridge::prepareMultiInsert ( )
abstractprotected

Build insert-fields for each "value".

Returns
array

Reimplemented in ilADTMultiEnumDBBridge, and ilADTMultiTextDBBridge.

Referenced by afterUpdate().

+ Here is the caller graph for this function:

◆ readMultiRecord()

ilADTMultiDBBridge::readMultiRecord (   $a_set)
abstractprotected

Import record-rows from sub-table.

Parameters
object$a_set

Reimplemented in ilADTMultiEnumDBBridge, and ilADTMultiTextDBBridge.

Referenced by readRecord().

+ Here is the caller graph for this function:

◆ readRecord()

ilADTMultiDBBridge::readRecord ( array  $a_row)

Import DB values to ADT.

Parameters
array$a_row

Reimplemented from ilADTDBBridge.

Reimplemented in ilADTMultiEnumDBBridge.

Definition at line 19 of file class.ilADTMultiDBBridge.php.

20 {
21 global $DIC;
22
23 $ilDB = $DIC['ilDB'];
24
25 $sql = "SELECT " . $this->getElementId() .
26 " FROM " . $this->getSubTableName() .
27 " WHERE " . $this->buildPrimaryWhere();
28 $set = $ilDB->query($sql);
29
30 $this->readMultiRecord($set);
31 }
readMultiRecord($a_set)
Import record-rows from sub-table.

References $DIC, $ilDB, ilADTDBBridge\buildPrimaryWhere(), ilADTDBBridge\getElementId(), getSubTableName(), and readMultiRecord().

+ Here is the call graph for this function:

The documentation for this class was generated from the following file: