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

Public Member Functions

 setFakeSingle ($a_status)
 
 readRecord (array $a_row)
 
 prepareInsert (array &$a_fields)
 
- Public Member Functions inherited from ilADTMultiDBBridge
 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...
 

Data Fields

const SEPARATOR = "~|~"
 

Protected Member Functions

 isValidADT (ilADT $a_adt)
 
 doSingleFake ()
 
 readMultiRecord ($a_set)
 
 prepareMultiInsert ()
 
- Protected Member Functions inherited from ilADTMultiDBBridge
 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...
 

Protected Attributes

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

Detailed Description

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

Member Function Documentation

◆ doSingleFake()

ilADTMultiEnumDBBridge::doSingleFake ( )
protected

Definition at line 21 of file class.ilADTMultiEnumDBBridge.php.

References $fake_single.

Referenced by prepareInsert(), and readRecord().

+ Here is the caller graph for this function:

◆ isValidADT()

ilADTMultiEnumDBBridge::isValidADT ( ilADT  $a_adt)
protected

Definition at line 11 of file class.ilADTMultiEnumDBBridge.php.

12  {
13  return ($a_adt instanceof ilADTMultiEnum);
14  }

◆ prepareInsert()

ilADTMultiEnumDBBridge::prepareInsert ( array &  $a_fields)

Definition at line 64 of file class.ilADTMultiEnumDBBridge.php.

References $values, doSingleFake(), ilADTDBBridge\getADT(), and ilADTDBBridge\getElementId().

65  {
66  if ($this->doSingleFake()) {
67  $values = (array) $this->getADT()->getSelections();
68  if (sizeof($values)) {
69  $values = self::SEPARATOR . implode(self::SEPARATOR, $values) . self::SEPARATOR;
70  }
71  $a_fields[$this->getElementId()] = array("text", $values);
72  }
73  }
getElementId()
Get element id.
$values
+ Here is the call graph for this function:

◆ prepareMultiInsert()

ilADTMultiEnumDBBridge::prepareMultiInsert ( )
protected

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

References $res, $type, ilADTDBBridge\getADT(), and ilADTDBBridge\getElementId().

76  {
77  $res = array();
78 
79  $type = ($this->getADT() instanceof ilADTMultiEnumNumeric)
80  ? "integer"
81  : "text";
82 
83  foreach ((array) $this->getADT()->getSelections() as $element) {
84  $res[] = array($this->getElementId() => array($type, $element));
85  }
86 
87  return $res;
88  }
foreach( $values as $value)
$type
getElementId()
Get element id.
foreach($_POST as $key=> $value) $res
+ Here is the call graph for this function:

◆ readMultiRecord()

ilADTMultiEnumDBBridge::readMultiRecord (   $a_set)
protected

Definition at line 49 of file class.ilADTMultiEnumDBBridge.php.

References $DIC, $ilDB, $row, ilADTDBBridge\getADT(), and ilADTDBBridge\getElementId().

Referenced by readRecord().

50  {
51  global $DIC;
52 
53  $ilDB = $DIC['ilDB'];
54 
55  $elements = array();
56 
57  while ($row = $ilDB->fetchAssoc($a_set)) {
58  $elements[] = $row[$this->getElementId()];
59  }
60 
61  $this->getADT()->setSelections($elements);
62  }
global $DIC
Definition: saml.php:7
getElementId()
Get element id.
$row
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readRecord()

ilADTMultiEnumDBBridge::readRecord ( array  $a_row)

Definition at line 26 of file class.ilADTMultiEnumDBBridge.php.

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

27  {
28  global $DIC;
29 
30  $ilDB = $DIC['ilDB'];
31 
32  if (!$this->doSingleFake()) {
33  $sql = "SELECT " . $this->getElementId() .
34  " FROM " . $this->getSubTableName() .
35  " WHERE " . $this->buildPrimaryWhere();
36  $set = $ilDB->query($sql);
37 
38  $this->readMultiRecord($set);
39  } else {
40  if (trim($a_row[$this->getElementId()])) {
41  $value = explode(self::SEPARATOR, $a_row[$this->getElementId()]);
42  array_pop($value);
43  array_shift($value);
44  $this->getADT()->setSelections($value);
45  }
46  }
47  }
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
+ Here is the call graph for this function:

◆ setFakeSingle()

ilADTMultiEnumDBBridge::setFakeSingle (   $a_status)

Definition at line 16 of file class.ilADTMultiEnumDBBridge.php.

17  {
18  $this->fake_single = (bool) $a_status;
19  }

Field Documentation

◆ $fake_single

ilADTMultiEnumDBBridge::$fake_single
protected

Definition at line 7 of file class.ilADTMultiEnumDBBridge.php.

Referenced by doSingleFake().

◆ SEPARATOR

const ilADTMultiEnumDBBridge::SEPARATOR = "~|~"

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