ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 72 of file class.ilADTMultiDBBridge.php.

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

73  {
74  global $ilDB;
75 
76  $ilDB->manipulate("DELETE FROM ".$this->getSubTableName().
77  " WHERE ".$this->buildPrimaryWhere());
78  }
buildPrimaryWhere()
Convert primary keys array to sql string.
getSubTableName()
Build sub-table name.
global $ilDB
+ Here is the call graph for this function:

◆ afterInsert()

ilADTMultiDBBridge::afterInsert ( )

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

References afterUpdate().

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

◆ afterUpdate()

ilADTMultiDBBridge::afterUpdate ( )

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

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

Referenced by afterInsert().

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  }
buildPrimaryWhere()
Convert primary keys array to sql string.
getSubTableName()
Build sub-table name.
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(), and afterUpdate().

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 38 of file class.ilADTMultiDBBridge.php.

39  {
40  // see afterUpdate()
41  }

◆ 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 $ilDB, and readMultiRecord().

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  }
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: