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

199  {
200 
201  }

◆ afterInsert()

ilADTDBBridge::afterInsert ( )

After insert hook to enable sub-tables.

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

172  {
173 
174  }

◆ afterUpdate()

ilADTDBBridge::afterUpdate ( )

After update hook to enable sub-tables.

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

191  {
192 
193  }

◆ buildPrimaryWhere()

ilADTDBBridge::buildPrimaryWhere ( )

Convert primary keys array to sql string.

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

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

References $ilDB, array, prepareInsert(), and readRecord().

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

136  {
137  global $ilDB;
138 
139  $sql = array();
140 
141  foreach($this->primary as $field => $def)
142  {
143  $sql[] = $field."=".$ilDB->quote($def[1], $def[0]);
144  }
145 
146  return implode(" AND ", $sql);
147  }
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:

◆ getADT()

◆ getElementId()

◆ getPrimary()

ilADTDBBridge::getPrimary ( )

Get primary fields.

Returns
array

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

References $primary.

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

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

◆ getTable()

ilADTDBBridge::getTable ( )

Get table name.

Returns
string

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

References $table.

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

85  {
86  return $this->table;
87  }
+ 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 182 of file class.ilADTDBBridge.php.

References prepareInsert().

183  {
184  $this->prepareInsert($a_fields);
185  }
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  {
53  throw new Exception('ADTDBBridge Type mismatch.');
54  }
55 
56  $this->adt = $a_adt;
57  }
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 94 of file class.ilADTDBBridge.php.

References string.

95  {
96  $this->id = (string)$a_value;
97  }
Add rich text string
The name of the decorator.

◆ setPrimary()

ilADTDBBridge::setPrimary ( array  $a_value)

Set primary fields (in MDB2 format)

Parameters
array$a_value

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

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

◆ setTable()

ilADTDBBridge::setTable (   $a_table)

Set table name.

Parameters
string$a_table

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

References string.

75  {
76  $this->table = (string)$a_table;
77  }
Add rich text string
The name of the decorator.

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: