ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 60 of file class.ilADTMultiEnumDBBridge.php.

References array, doSingleFake(), ilADTDBBridge\getADT(), and ilADTDBBridge\getElementId().

61  {
62  if ($this->doSingleFake()) {
63  $values = (array) $this->getADT()->getSelections();
64  if (sizeof($values)) {
65  $values = self::SEPARATOR . implode(self::SEPARATOR, $values) . self::SEPARATOR;
66  }
67  $a_fields[$this->getElementId()] = array("text", $values);
68  }
69  }
getElementId()
Get element id.
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ prepareMultiInsert()

ilADTMultiEnumDBBridge::prepareMultiInsert ( )
protected

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

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

72  {
73  $res = array();
74 
75  $type = ($this->getADT() instanceof ilADTMultiEnumNumeric)
76  ? "integer"
77  : "text";
78 
79  foreach ((array) $this->getADT()->getSelections() as $element) {
80  $res[] = array($this->getElementId() => array($type, $element));
81  }
82 
83  return $res;
84  }
$type
foreach( $files as $file)
getElementId()
Get element id.
foreach($_POST as $key=> $value) $res
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ readMultiRecord()

ilADTMultiEnumDBBridge::readMultiRecord (   $a_set)
protected

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

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

Referenced by readRecord().

48  {
49  global $ilDB;
50 
51  $elements = array();
52 
53  while ($row = $ilDB->fetchAssoc($a_set)) {
54  $elements[] = $row[$this->getElementId()];
55  }
56 
57  $this->getADT()->setSelections($elements);
58  }
getElementId()
Get element id.
Create styles array
The data for the language used.
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 $ilDB, ilADTDBBridge\buildPrimaryWhere(), doSingleFake(), ilADTDBBridge\getADT(), ilADTDBBridge\getElementId(), ilADTMultiDBBridge\getSubTableName(), and readMultiRecord().

27  {
28  global $ilDB;
29 
30  if (!$this->doSingleFake()) {
31  $sql = "SELECT " . $this->getElementId() .
32  " FROM " . $this->getSubTableName() .
33  " WHERE " . $this->buildPrimaryWhere();
34  $set = $ilDB->query($sql);
35 
36  $this->readMultiRecord($set);
37  } else {
38  if (trim($a_row[$this->getElementId()])) {
39  $value = explode(self::SEPARATOR, $a_row[$this->getElementId()]);
40  array_pop($value);
41  array_shift($value);
42  $this->getADT()->setSelections($value);
43  }
44  }
45  }
buildPrimaryWhere()
Convert primary keys array to sql string.
getSubTableName()
Build sub-table name.
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: