ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 72 of file class.ilADTMultiDBBridge.php.

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

References $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 43 of file class.ilADTMultiDBBridge.php.

44 {
45 $this->afterUpdate();
46 }
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 48 of file class.ilADTMultiDBBridge.php.

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 }
getPrimary()
Get primary fields.
prepareMultiInsert()
Build insert-fields for each "value".

References $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(), and afterUpdate().

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

39 {
40 // see afterUpdate()
41 }

◆ 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 $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 }
readMultiRecord($a_set)
Import record-rows from sub-table.

References $ilDB, and readMultiRecord().

+ Here is the call graph for this function:

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