ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilADTMultiDBBridge Class Reference
+ Inheritance diagram for ilADTMultiDBBridge:
+ Collaboration diagram for ilADTMultiDBBridge:

Public Member Functions

 readRecord (array $a_row)
 
 prepareInsert (array &$a_fields)
 
 afterInsert ()
 
 afterUpdate ()
 
 afterDelete ()
 
- 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 ( )

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

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

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 $DIC
Definition: saml.php:7
global $ilDB
+ Here is the call graph for this function:

◆ afterInsert()

ilADTMultiDBBridge::afterInsert ( )

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

References afterUpdate().

46  {
47  $this->afterUpdate();
48  }
+ Here is the call graph for this function:

◆ afterUpdate()

ilADTMultiDBBridge::afterUpdate ( )

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

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

Referenced by afterInsert().

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  }
buildPrimaryWhere()
Convert primary keys array to sql string.
getSubTableName()
Build sub-table name.
global $DIC
Definition: saml.php:7
getPrimary()
Get primary fields.
prepareMultiInsert()
Build insert-fields for each "value".
global $ilDB
+ 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.

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

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

15  {
16  return $this->getTable() . "_" . $this->getElementId();
17  }
getTable()
Get table name.
getElementId()
Get element id.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ prepareInsert()

ilADTMultiDBBridge::prepareInsert ( array &  $a_fields)

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

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

Referenced by readRecord().

+ Here is the caller graph for this function:

◆ readRecord()

ilADTMultiDBBridge::readRecord ( array  $a_row)

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

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

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  }
buildPrimaryWhere()
Convert primary keys array to sql string.
getSubTableName()
Build sub-table name.
global $DIC
Definition: saml.php:7
getElementId()
Get element id.
global $ilDB
readMultiRecord($a_set)
Import record-rows from sub-table.
+ Here is the call graph for this function:

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