ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilADTDBBridge Class Reference

ADT DB bridge base class. More...

+ Inheritance diagram for ilADTDBBridge:
+ Collaboration diagram for ilADTDBBridge:

Public Member Functions

 __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

 isValidADT (ilADT $a_adt)
 Check if given ADT is valid. More...
 
 setADT (ilADT $a_adt)
 Set ADT. More...
 

Protected Attributes

 $adt
 
 $table
 
 $id
 
 $primary = []
 

Detailed Description

ADT DB bridge base class.

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

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

Constructor & Destructor Documentation

◆ __construct()

ilADTDBBridge::__construct ( ilADT  $a_adt)

Constructor.

Parameters
ilADT$a_adt
Returns
self

Definition at line 24 of file class.ilADTDBBridge.php.

References isValidADT(), and setADT().

25  {
26  $this->setADT($a_adt);
27  }
setADT(ilADT $a_adt)
Set ADT.
+ Here is the call graph for this function:

Member Function Documentation

◆ afterDelete()

ilADTDBBridge::afterDelete ( )

After delete hook to enable sub-tables.

Definition at line 196 of file class.ilADTDBBridge.php.

197  {
198  }

◆ afterInsert()

ilADTDBBridge::afterInsert ( )

After insert hook to enable sub-tables.

Definition at line 171 of file class.ilADTDBBridge.php.

172  {
173  }

◆ afterUpdate()

ilADTDBBridge::afterUpdate ( )

After update hook to enable sub-tables.

Definition at line 189 of file class.ilADTDBBridge.php.

190  {
191  }

◆ buildPrimaryWhere()

ilADTDBBridge::buildPrimaryWhere ( )

Convert primary keys array to sql string.

See also
ilADTActiveRecord (:TODO: needed for multi)
Returns
string

Definition at line 134 of file class.ilADTDBBridge.php.

References $def, $DIC, $ilDB, prepareInsert(), and readRecord().

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

135  {
136  global $DIC;
137 
138  $ilDB = $DIC['ilDB'];
139 
140  $sql = array();
141 
142  foreach ($this->primary as $field => $def) {
143  $sql[] = $field . "=" . $ilDB->quote($def[1], $def[0]);
144  }
145 
146  return implode(" AND ", $sql);
147  }
global $DIC
Definition: saml.php:7
global $ilDB
$def
Definition: croninfo.php:21
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getADT()

◆ getElementId()

◆ getPrimary()

ilADTDBBridge::getPrimary ( )

Get primary fields.

Returns
array

Definition at line 123 of file class.ilADTDBBridge.php.

References $primary.

Referenced by ilADTMultiDBBridge\afterUpdate(), ilADTGroupDBBridge\prepareElements(), and ilADTGroupDBBridge\setPrimary().

124  {
125  return $this->primary;
126  }
+ Here is the caller graph for this function:

◆ getTable()

ilADTDBBridge::getTable ( )

Get table name.

Returns
string

Definition at line 83 of file class.ilADTDBBridge.php.

References $table.

Referenced by ilADTMultiDBBridge\getSubTableName(), ilADTGroupDBBridge\prepareElements(), and ilADTGroupDBBridge\setTable().

84  {
85  return $this->table;
86  }
+ Here is the caller graph for this function:

◆ isValidADT()

ilADTDBBridge::isValidADT ( ilADT  $a_adt)
abstractprotected

Check if given ADT is valid.

:TODO: This could be avoided with type-specifc constructors :TODO: bridge base class?

Parameters
ilADT$a_adt

Referenced by __construct(), and setADT().

+ Here is the caller graph for this function:

◆ prepareInsert()

ilADTDBBridge::prepareInsert ( array &  $a_fields)
abstract

Prepare ADT values for insert.

Parameters
array&$a_fields

Referenced by buildPrimaryWhere(), and prepareUpdate().

+ Here is the caller graph for this function:

◆ prepareUpdate()

ilADTDBBridge::prepareUpdate ( array &  $a_fields)

Prepare ADT values for update.

See also
prepareInsert()
Parameters
array&$a_fields

Definition at line 181 of file class.ilADTDBBridge.php.

References prepareInsert().

182  {
183  $this->prepareInsert($a_fields);
184  }
prepareInsert(array &$a_fields)
Prepare ADT values for insert.
+ Here is the call graph for this function:

◆ readRecord()

ilADTDBBridge::readRecord ( array  $a_row)
abstract

Import DB values to ADT.

Parameters
array$a_row

Referenced by buildPrimaryWhere().

+ Here is the caller graph for this function:

◆ setADT()

ilADTDBBridge::setADT ( ilADT  $a_adt)
protected

Set ADT.

Exceptions
Exception
Parameters
ilADT$a_adt

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

References isValidADT().

Referenced by __construct().

50  {
51  if (!$this->isValidADT($a_adt)) {
52  throw new Exception('ADTDBBridge Type mismatch.');
53  }
54 
55  $this->adt = $a_adt;
56  }
isValidADT(ilADT $a_adt)
Check if given ADT is valid.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setElementId()

ilADTDBBridge::setElementId (   $a_value)

Set element id (aka DB column[s] [prefix])

Parameters
string$a_value

Definition at line 93 of file class.ilADTDBBridge.php.

94  {
95  $this->id = (string) $a_value;
96  }

◆ setPrimary()

ilADTDBBridge::setPrimary ( array  $a_value)

Set primary fields (in MDB2 format)

Parameters
array$a_value

Definition at line 113 of file class.ilADTDBBridge.php.

114  {
115  $this->primary = $a_value;
116  }

◆ setTable()

ilADTDBBridge::setTable (   $a_table)

Set table name.

Parameters
string$a_table

Definition at line 73 of file class.ilADTDBBridge.php.

74  {
75  $this->table = (string) $a_table;
76  }

Field Documentation

◆ $adt

ilADTDBBridge::$adt
protected

Definition at line 13 of file class.ilADTDBBridge.php.

Referenced by getADT().

◆ $id

ilADTDBBridge::$id
protected

Definition at line 15 of file class.ilADTDBBridge.php.

Referenced by getElementId().

◆ $primary

ilADTDBBridge::$primary = []
protected

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

Referenced by getPrimary().

◆ $table

ilADTDBBridge::$table
protected

Definition at line 14 of file class.ilADTDBBridge.php.

Referenced by getTable().


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