ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilADTActiveRecordWrapper Class Reference

ADT Active Record service wrapper class. More...

+ Inheritance diagram for ilADTActiveRecordWrapper:
+ Collaboration diagram for ilADTActiveRecordWrapper:

Public Member Functions

 __construct (ilADTGroupActiveRecordBridge $a_properties)
 Constructor. More...
 
 getConnectorContainerName ()
 
 getPrimaryFieldValue ()
 
 sleep ($field_name)
 
 wakeUp ($field_name, $field_value)
 
- Public Member Functions inherited from ActiveRecord
 getArConnector ()
 
 getArFieldList ()
 
 getConnectorContainerName ()
 
 setConnectorContainerName ($connector_container_name)
 
 getPrimaryFieldValue ()
 
 setPrimaryFieldValue ($value)
 
 __construct ($primary_key=0, arConnector $connector=null)
 
 storeObjectToCache ()
 
 __getConvertedDateFieldsAsArray ($format=null)
 
 __asCsv ($separator=';', $header=false)
 
 __asArray ()
 
 __asStdClass ()
 
 __asSerializedObject ()
 
 buildFromArray (array $array)
 
 fixDateField ($field_name, $value)
 
 sleep ($field_name)
 
 wakeUp ($field_name, $field_value)
 
 getArrayForDb ()
 
 getArrayForConnector ()
 
 installConnector ()
 
 store ()
 
 save ()
 
 create ()
 
 copy ($new_id=0)
 
 afterObjectLoad ()
 
 read ()
 
 update ()
 
 delete ()
 
 __call ($name, $arguments)
 

Static Public Member Functions

static returnDbTableName ()
 
- Static Public Member Functions inherited from ActiveRecord
static returnDbTableName ()
 
static installDB ()
 
static renameDBField ($old_name, $new_name)
 
static tableExists ()
 
static fieldExists ($field_name)
 
static removeDBField ($field_name)
 
static updateDB ()
 
static resetDB ()
 
static truncateDB ()
 
static flushDB ()
 
static preloadObjects ()
 
static additionalParams (array $additional_params)
 
static findOrFail ($primary_key, array $add_constructor_args=array())
 Tries to find the object and throws an Exception if object is not found, instead of returning null. More...
 
static findOrGetInstance ($primary_key, array $add_constructor_args=array())
 
static where ($where, $operator=null)
 
static innerjoinAR (ActiveRecord $ar, $on_this, $on_external, $fields=array(' *'), $operator='=', $both_external=false)
 
static innerjoin ($tablename, $on_this, $on_external, $fields=array(' *'), $operator='=', $both_external=false)
 
static leftjoin ($tablename, $on_this, $on_external, $fields=array(' *'), $operator='=', $both_external=false)
 
static orderBy ($orderBy, $orderDirection='ASC')
 
static dateFormat ($date_format='d.m.Y - H:i:s')
 
static limit ($start, $end)
 
static affectedRows ()
 
static count ()
 
static get ()
 
static debug ()
 
static first ()
 
static getCollection ()
 
static last ()
 
static getFirstFromLastQuery ()
 
static connector (arConnector $connector)
 
static raw ($set_raw=true)
 
static getArray ($key=null, $values=null)
 
static _toCamelCase ($str, $capitalise_first_char=false)
 

Protected Member Functions

 getActiveRecordFieldTypeFromMDB2 ($a_mdb2_type)
 
 initFieldList ()
 Get field list instance for ADT group. More...
 
- Protected Member Functions inherited from ActiveRecord
 serializeToCSV ($field)
 This method is called for every field of your instance if you use __asCsv. More...
 
 installDatabase ()
 

Protected Attributes

 $properties
 
 $fields
 
 $field_element_map = []
 
- Protected Attributes inherited from ActiveRecord
 $ar_safe_read = true
 
 $connector_container_name = ''
 

Additional Inherited Members

- Data Fields inherited from ActiveRecord
const ACTIVE_RECORD_VERSION = '2.0.7'
 
- Static Protected Member Functions inherited from ActiveRecord
static getCalledClass ()
 
static fromCamelCase ($str)
 

Detailed Description

ADT Active Record service wrapper class.

:TODO: EXPERIMENTAL!

This class expects a valid primary for all actions!

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 17 of file class.ilADTActiveRecordWrapper.php.

Constructor & Destructor Documentation

◆ __construct()

ilADTActiveRecordWrapper::__construct ( ilADTGroupActiveRecordBridge  $a_properties)

Constructor.

Parameters
ilADTGroupActiveRecordBridge$a_properties
Returns
self

Definition at line 29 of file class.ilADTActiveRecordWrapper.php.

References initFieldList(), and properties.

30  {
31  $this->properties = $a_properties;
32 
33  // see ActiveRecord::__construct();
34  $this->initFieldList();
35  $this->arConnector = new arConnectorDB();
36  }
initFieldList()
Get field list instance for ADT group.
Class arConnectorDB.
Class arConnector.
Set document properties
+ Here is the call graph for this function:

Member Function Documentation

◆ getActiveRecordFieldTypeFromMDB2()

ilADTActiveRecordWrapper::getActiveRecordFieldTypeFromMDB2 (   $a_mdb2_type)
protected

Definition at line 43 of file class.ilADTActiveRecordWrapper.php.

References arField\FIELD_TYPE_DATE, arField\FIELD_TYPE_FLOAT, arField\FIELD_TYPE_INTEGER, arField\FIELD_TYPE_TEXT, and arField\FIELD_TYPE_TIMESTAMP.

Referenced by initFieldList().

44  {
45  // currently they are all the same
46  switch ($a_mdb2_type) {
47  case "integer":
49 
50  case "float":
52 
53  case "text":
55 
56  case "date":
58 
59  case "timestamp":
61 
62  case "integer":
64 
65  /*
66  case "clob":
67  return arField::FIELD_TYPE_CLOB;
68 
69  case "time":
70  return arField::FIELD_TYPE_TIME;
71  */
72  }
73  }
const FIELD_TYPE_FLOAT
const FIELD_TYPE_TEXT
const FIELD_TYPE_INTEGER
const FIELD_TYPE_DATE
const FIELD_TYPE_TIMESTAMP
+ Here is the caller graph for this function:

◆ getConnectorContainerName()

ilADTActiveRecordWrapper::getConnectorContainerName ( )

Definition at line 117 of file class.ilADTActiveRecordWrapper.php.

References properties.

118  {
119  return $this->properties->getTableName();
120  }
Set document properties

◆ getPrimaryFieldValue()

ilADTActiveRecordWrapper::getPrimaryFieldValue ( )

Definition at line 127 of file class.ilADTActiveRecordWrapper.php.

References properties.

128  {
129  $primary = array_shift($this->properties->getPrimary());
130  return $primary[1];
131  }
Set document properties

◆ initFieldList()

ilADTActiveRecordWrapper::initFieldList ( )
protected

Get field list instance for ADT group.

Definition at line 78 of file class.ilADTActiveRecordWrapper.php.

References $fields, array, fields, getActiveRecordFieldTypeFromMDB2(), and properties.

Referenced by __construct().

79  {
80  require_once "Services/ActiveRecord/classes/Fields/class.arFieldList.php";
81  $this->fields = new arFieldList();
82 
83  // element => fields
84 
85  $fields = array();
86  foreach ($this->properties->getActiveRecordFields() as $element_id => $element_fields) {
87  foreach ($element_fields as $field) {
88  $this->field_element_map[$field->getName()] = $element_id;
89  }
90 
91  $fields = array_merge($fields, $element_fields);
92  }
93 
94  $this->fields->setFields($fields);
95 
96  // primary
97 
98  if (sizeof($this->properties->getPrimary()) > 1) {
99  throw new ilException("ilADTActiveRecordWrapper - no complex primary keys supported yet");
100  }
101 
102  foreach ($this->properties->getPrimary() as $primary_id => $primary_element) {
103  $field = new arField();
104  $field->setHasField(true);
105  $field->setNotNull(true);
106  $field->setFieldType($this->getActiveRecordFieldTypeFromMDB2($primary_element[0]));
107  $field->setName($primary_id);
108  $this->fields->setPrimaryField($field);
109  }
110  }
Class arField.
$errors fields
Definition: imgupload.php:51
Create styles array
The data for the language used.
Class arFieldList.
Set document properties
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ returnDbTableName()

static ilADTActiveRecordWrapper::returnDbTableName ( )
static

Definition at line 122 of file class.ilADTActiveRecordWrapper.php.

123  {
124  // :TODO: cannot be static
125  }

◆ sleep()

ilADTActiveRecordWrapper::sleep (   $field_name)

Definition at line 138 of file class.ilADTActiveRecordWrapper.php.

References properties.

139  {
140  if (array_key_exists($field_name, $this->field_element_map)) {
141  $element = $this->properties->getElement($this->field_element_map[$field_name]);
142  return $element->getFieldValue($field_name);
143  }
144 
145  // returning NULL would result in direct property access!
146  return false;
147  }
Set document properties

◆ wakeUp()

ilADTActiveRecordWrapper::wakeUp (   $field_name,
  $field_value 
)

Definition at line 149 of file class.ilADTActiveRecordWrapper.php.

References properties.

150  {
151  if (array_key_exists($field_name, $this->field_element_map)) {
152  $element = $this->properties->getElement($this->field_element_map[$field_name]);
153  return $element->setFieldValue($field_name, $field_value);
154  }
155 
156  // returning NULL would result in direct property access!
157  return false;
158  }
Set document properties

Field Documentation

◆ $field_element_map

ilADTActiveRecordWrapper::$field_element_map = []
protected

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

◆ $fields

ilADTActiveRecordWrapper::$fields
protected

Definition at line 20 of file class.ilADTActiveRecordWrapper.php.

Referenced by initFieldList().

◆ $properties

ilADTActiveRecordWrapper::$properties
protected

Definition at line 19 of file class.ilADTActiveRecordWrapper.php.


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