ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ActiveRecord Class Reference

Class ActiveRecord. More...

+ Inheritance diagram for ActiveRecord:
+ Collaboration diagram for ActiveRecord:

Public Member Functions

 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 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)
 

Data Fields

const ACTIVE_RECORD_VERSION = '2.0.7'
 

Protected Member Functions

 serializeToCSV ($field)
 This method is called for every field of your instance if you use __asCsv. More...
 
 installDatabase ()
 

Static Protected Member Functions

static getCalledClass ()
 
static fromCamelCase ($str)
 

Protected Attributes

 $ar_safe_read = true
 
 $connector_container_name = ''
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ActiveRecord::__construct (   $primary_key = 0,
arConnector  $connector = null 
)
Parameters
int$primary_key
arConnector$connector

Definition at line 110 of file class.ActiveRecord.php.

References arFieldCache\get(), read(), and arConnectorMap\register().

110  {
111  if ($connector == null) {
112  $connector = new arConnectorDB();
113  }
114  arConnectorMap::register($this, $connector);
115 
116  $arFieldList = arFieldCache::get($this);
117 
118  $key = $arFieldList->getPrimaryFieldName();
119  $this->{$key} = $primary_key;
120  if ($primary_key !== 0 AND $primary_key !== null AND $primary_key !== false) {
121  $this->read();
122  }
123  }
Class arConnectorDB.
static register(ActiveRecord $ar, arConnector $connector)
static get(ActiveRecord $ar)
+ Here is the call graph for this function:

Member Function Documentation

◆ __asArray()

ActiveRecord::__asArray ( )
Returns
array

Definition at line 199 of file class.ActiveRecord.php.

References array, and getArFieldList().

Referenced by __asCsv().

199  {
200  $return = array();
201  foreach ($this->getArFieldList()->getFields() as $field) {
202  $fieldname = $field->getName();
203  $return[$fieldname] = $this->{$fieldname};
204  }
205 
206  return $return;
207  }
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __asCsv()

ActiveRecord::__asCsv (   $separator = ';',
  $header = false 
)
Parameters
string$separator
bool$header
Returns
string

Definition at line 162 of file class.ActiveRecord.php.

References $header, __asArray(), array, getArFieldList(), and serializeToCSV().

162  {
163  $line = '';
164  if ($header) {
165  $line .= implode($separator, array_keys($this->getArFieldList()->getRawFields()));
166  $line .= "\n";
167  }
168  $array = array();
169  foreach ($this->__asArray() as $field_name => $value) {
170  $serialized = $this->serializeToCSV($field_name);
171  if ($serialized === null) {
172  $array[$field_name] = $this->{$field_name};
173  } else {
174  $array[$field_name] = $serialized;
175  }
176  }
177  $line .= implode($separator, array_values($array));
178 
179  return $line;
180  }
$header
Create styles array
The data for the language used.
serializeToCSV($field)
This method is called for every field of your instance if you use __asCsv.
+ Here is the call graph for this function:

◆ __asSerializedObject()

ActiveRecord::__asSerializedObject ( )
Returns
string

Definition at line 227 of file class.ActiveRecord.php.

227  {
228  return serialize($this);
229  }

◆ __asStdClass()

ActiveRecord::__asStdClass ( )
Returns
stdClass

Definition at line 213 of file class.ActiveRecord.php.

References getArFieldList().

Referenced by arConnectorSession\create().

213  {
214  $return = new stdClass();
215  foreach ($this->getArFieldList()->getFields() as $field) {
216  $fieldname = $field->getName();
217  $return->{$fieldname} = $this->{$fieldname};
218  }
219 
220  return $return;
221  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __call()

ActiveRecord::__call (   $name,
  $arguments 
)
Parameters
$name
$arguments
Returns
array

Definition at line 862 of file class.ActiveRecord.php.

References array, and count().

862  {
863  // Getter
864  if (preg_match("/get([a-zA-Z]*)/u", $name, $matches) AND count($arguments) == 0) {
865  return $this->{self::fromCamelCase($matches[1])};
866  }
867  // Setter
868  if (preg_match("/set([a-zA-Z]*)/u", $name, $matches) AND count($arguments) == 1) {
869  $this->{self::fromCamelCase($matches[1])} = $arguments[0];
870  }
871  if (preg_match("/findBy([a-zA-Z]*)/u", $name, $matches) AND count($arguments) == 1) {
872  return self::where(array( self::fromCamelCase($matches[1]) => $arguments[0] ))->getFirst();
873  }
874  }
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ __getConvertedDateFieldsAsArray()

ActiveRecord::__getConvertedDateFieldsAsArray (   $format = null)
Parameters
string$format
Returns
array

Definition at line 136 of file class.ActiveRecord.php.

References array, date, and getArFieldList().

136  {
137  $converted_dates = array();
138  foreach ($this->getArFieldList()->getFields() as $field) {
139  if ($field->isDateField()) {
140  $name = $field->getName();
141  $value = $this->{$name};
142  $converted_dates[$name] = array(
143  'unformatted' => $value,
144  'unix' => strtotime($value),
145  );
146  if ($format) {
147  $converted_dates[$name]['formatted'] = date($format, strtotime($value));
148  }
149  }
150  }
151 
152  return $converted_dates;
153  }
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ _toCamelCase()

static ActiveRecord::_toCamelCase (   $str,
  $capitalise_first_char = false 
)
static
Parameters
string$str
bool$capitalise_first_char
Returns
string

Definition at line 883 of file class.ActiveRecord.php.

Referenced by arViewField\__construct().

883  {
884  if ($capitalise_first_char) {
885  $str[0] = strtoupper($str[0]);
886  }
887  $func = create_function('$c', 'return strtoupper($c[1]);');
888 
889  return preg_replace_callback('/_([a-z])/', $func, $str);
890  }
+ Here is the caller graph for this function:

◆ additionalParams()

static ActiveRecord::additionalParams ( array  $additional_params)
static
Parameters
array$additional_params
Returns
$this

Definition at line 555 of file class.ActiveRecord.php.

References array, arObjectCache\get(), and arObjectCache\isCached().

555  {
556  $srModelObjectList = new ActiveRecordList(self::getCalledClass());
557  $srModelObjectList->additionalParams($additional_params);
558 
559  return $srModelObjectList;
560  }
Class ActiveRecordList.
+ Here is the call graph for this function:

◆ affectedRows()

static ActiveRecord::affectedRows ( )
static
Returns
int

Definition at line 741 of file class.ActiveRecord.php.

741  {
742  $srModelObjectList = new ActiveRecordList(self::getCalledClass());
743 
744  return $srModelObjectList->affectedRows();
745  }
Class ActiveRecordList.

◆ afterObjectLoad()

ActiveRecord::afterObjectLoad ( )

Definition at line 501 of file class.ActiveRecord.php.

Referenced by buildFromArray(), and read().

501  {
502  }
+ Here is the caller graph for this function:

◆ buildFromArray()

ActiveRecord::buildFromArray ( array  $array)
Parameters
array$array
Returns
$this

Definition at line 237 of file class.ActiveRecord.php.

References afterObjectLoad(), arObjectCache\get(), getArFieldList(), arObjectCache\isCached(), arObjectCache\store(), and wakeUp().

237  {
238  $class = get_class($this);
239  $primary = $this->getArFieldList()->getPrimaryFieldName();
240  $primary_value = $array[$primary];
241  if ($primary_value AND arObjectCache::isCached($class, $primary_value)) {
242  return arObjectCache::get($class, $primary_value);
243  }
244  foreach ($array as $field_name => $value) {
245  if ($this->wakeUp($field_name, $value) === null) {
246  $this->{$field_name} = $value;
247  } else {
248  $this->{$field_name} = $this->wakeUp($field_name, $value);
249  }
250  }
251  arObjectCache::store($this);
252  $this->afterObjectLoad();
253 
254  return $this;
255  }
static store(ActiveRecord $object)
static get($class, $id)
wakeUp($field_name, $field_value)
static isCached($class, $id)
+ Here is the call graph for this function:

◆ connector()

static ActiveRecord::connector ( arConnector  $connector)
static
Parameters
arConnector$connector
Returns
ActiveRecordList

Definition at line 822 of file class.ActiveRecord.php.

822  {
823  $srModelObjectList = new ActiveRecordList(self::getCalledClass());
824 
825  return $srModelObjectList->connector($connector);
826  }
Class ActiveRecordList.

◆ copy()

ActiveRecord::copy (   $new_id = 0)
Parameters
int$new_id
Returns
ActiveRecord
Exceptions
arException

Definition at line 490 of file class.ActiveRecord.php.

References array, arException\COPY_DESTINATION_ID_EXISTS, and getArFieldList().

490  {
491  if (self::where(array( $this->getArFieldList()->getPrimaryFieldName() => $new_id ))->hasSets()) {
493  }
494  $new_obj = clone($this);
495  $new_obj->setPrimaryFieldValue($new_id);
496 
497  return $new_obj;
498  }
const COPY_DESTINATION_ID_EXISTS
Create styles array
The data for the language used.
Class arException.
+ Here is the call graph for this function:

◆ count()

◆ create()

ActiveRecord::create ( )

Definition at line 473 of file class.ActiveRecord.php.

References getArConnector(), getArFieldList(), getArrayForConnector(), arFieldCache\getPrimaryFieldName(), and arObjectCache\store().

Referenced by ilDclTableViewFieldSetting\cloneStructure(), ilDclTableView\cloneStructure(), ilStudyProgrammeType\getAllTypesArray(), ilOrgUnitPathStorage\store(), and store().

473  {
474  if ($this->getArFieldList()->getPrimaryField()->getSequence()) {
475  $primary_fieldname = arFieldCache::getPrimaryFieldName($this);
476  $this->{$primary_fieldname} = $this->getArConnector()->nextID($this);
477  }
478 
479  $this->getArConnector()->create($this, $this->getArrayForConnector());
480  arObjectCache::store($this);
481  }
static getPrimaryFieldName(ActiveRecord $ar)
static store(ActiveRecord $object)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dateFormat()

static ActiveRecord::dateFormat (   $date_format = 'd.m.Y - H:i:s')
static
Parameters
string$date_format
Returns
ActiveRecordList

Definition at line 716 of file class.ActiveRecord.php.

716  :i:s') {
717  $srModelObjectList = new ActiveRecordList(self::getCalledClass());
718  $srModelObjectList->dateFormat($date_format);
719 
720  return $srModelObjectList;
721  }

◆ debug()

static ActiveRecord::debug ( )
static
Returns
ActiveRecordList

Definition at line 769 of file class.ActiveRecord.php.

769  {
770  $srModelObjectList = new ActiveRecordList(self::getCalledClass());
771 
772  return $srModelObjectList->debug();
773  }
Class ActiveRecordList.

◆ delete()

ActiveRecord::delete ( )

Definition at line 532 of file class.ActiveRecord.php.

References getArConnector(), and arObjectCache\purge().

532  {
533  $this->getArConnector()->delete($this);
534  arObjectCache::purge($this);
535  }
static purge(ActiveRecord $object)
+ Here is the call graph for this function:

◆ fieldExists()

static ActiveRecord::fieldExists (   $field_name)
staticfinal
Parameters
$field_name
Returns
bool

Definition at line 384 of file class.ActiveRecord.php.

384  {
385  return self::getCalledClass()->getArConnector()->checkFieldExists(self::getCalledClass(), $field_name);
386  }

◆ findOrFail()

static ActiveRecord::findOrFail (   $primary_key,
array  $add_constructor_args = array() 
)
static

Tries to find the object and throws an Exception if object is not found, instead of returning null.

Parameters
$primary_key
array$add_constructor_args
Exceptions
arException
Returns
ActiveRecord

Definition at line 603 of file class.ActiveRecord.php.

References arException\RECORD_NOT_FOUND.

Referenced by ilObjDefReader\handlerBeginTag().

603  {
604  $obj = self::find($primary_key, $add_constructor_args);
605  if (is_null($obj)) {
607  }
608 
609  return $obj;
610  }
Class arException.
+ Here is the caller graph for this function:

◆ findOrGetInstance()

static ActiveRecord::findOrGetInstance (   $primary_key,
array  $add_constructor_args = array() 
)
static
Parameters
$primary_key
array$add_constructor_argsReturns an existing Object with given primary-key or a new Instance with given primary-key set but not yet created
Returns
ActiveRecord

Definition at line 621 of file class.ActiveRecord.php.

Referenced by ilDclTableViewGUI\executeCommand().

621  {
622  $obj = self::find($primary_key, $add_constructor_args);
623  if ($obj !== null) {
624  return $obj;
625  } else {
626  $class_name = get_called_class();
627  $obj = arFactory::getInstance($class_name, 0, $add_constructor_args);
628  $obj->setPrimaryFieldValue($primary_key);
629  $obj->is_new = true;
630  $obj->storeObjectToCache();
631 
632  return $obj;
633  }
634  }
+ Here is the caller graph for this function:

◆ first()

static ActiveRecord::first ( )
static
Returns
ActiveRecord

Definition at line 779 of file class.ActiveRecord.php.

Referenced by ilDclTableView\createOrGetStandardView(), and ilDclTableViewFieldSetting\getInstance().

779  {
780  $srModelObjectList = new ActiveRecordList(self::getCalledClass());
781 
782  return $srModelObjectList->first();
783  }
Class ActiveRecordList.
+ Here is the caller graph for this function:

◆ fixDateField()

ActiveRecord::fixDateField (   $field_name,
  $value 
)
Parameters
$field_name
$value
Returns
string

Definition at line 263 of file class.ActiveRecord.php.

References getArConnector(), and getArFieldList().

263  {
264  if ($this->getArFieldList()->getFieldByName($field_name)->isDateField()) {
265  return $this->getArConnector()->fixDate($value);
266  }
267 
268  return $value;
269  }
+ Here is the call graph for this function:

◆ flushDB()

static ActiveRecord::flushDB ( )
staticfinal
Returns
bool

Definition at line 449 of file class.ActiveRecord.php.

449  {
450  return self::truncateDB();
451  }

◆ fromCamelCase()

static ActiveRecord::fromCamelCase (   $str)
staticprotected
Parameters
string$str
Returns
string

Definition at line 898 of file class.ActiveRecord.php.

898  {
899  $str[0] = strtolower($str[0]);
900  $func = create_function('$c', 'return "_" . strtolower($c[1]);');
901 
902  return preg_replace_callback('/([A-Z])/', $func, $str);
903  }

◆ get()

static ActiveRecord::get ( )
static
Returns
ActiveRecord[]

Definition at line 759 of file class.ActiveRecord.php.

Referenced by arConfigFormGUI\getValuesForItem().

759  {
760  $srModelObjectList = new ActiveRecordList(self::getCalledClass());
761 
762  return $srModelObjectList->get();
763  }
Class ActiveRecordList.
+ Here is the caller graph for this function:

◆ getArConnector()

ActiveRecord::getArConnector ( )
Returns

Definition at line 40 of file class.ActiveRecord.php.

References arConnectorMap\get().

Referenced by arWhere\asSQLStatement(), create(), delete(), fixDateField(), installDatabase(), read(), and update().

40  {
41  return arConnectorMap::get($this);
42  }
static get(ActiveRecord $ar)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getArFieldList()

ActiveRecord::getArFieldList ( )

◆ getArray()

static ActiveRecord::getArray (   $key = null,
  $values = null 
)
static
Parameters
null$key
null$values
Returns
array

Definition at line 847 of file class.ActiveRecord.php.

Referenced by ilOrgUnitPathStorage\getTextRepresentationOfOrgUnits(), and ilMemcacheServerTableGUI\parseData().

847  {
848  $srModelObjectList = new ActiveRecordList(self::getCalledClass());
849 
850  return $srModelObjectList->getArray($key, $values);
851  }
Class ActiveRecordList.
+ Here is the caller graph for this function:

◆ getArrayForConnector()

ActiveRecord::getArrayForConnector ( )
final
Returns
array

Definition at line 305 of file class.ActiveRecord.php.

References $data, array, getArFieldList(), and sleep().

Referenced by arConnectorDB\create(), create(), getArrayForDb(), arStorage\mapFromActiveRecord(), arStorage\mapToActiveRecord(), read(), and arConnectorDB\update().

305  {
306  $data = array();
307  foreach ($this->getArFieldList()->getFields() as $field) {
308  $field_name = $field->getName();
309  $sleeped = $this->sleep($field_name);
310  $var = ($sleeped === null) ? ($this->{$field_name}) : $sleeped;
311  $data[$field_name] = array( $field->getFieldType(), $var );
312  }
313 
314  return $data;
315  }
sleep($field_name)
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getArrayForDb()

ActiveRecord::getArrayForDb ( )
final
Returns
array
Deprecated:

Definition at line 297 of file class.ActiveRecord.php.

References getArrayForConnector().

297  {
298  return $this->getArrayForConnector();
299  }
+ Here is the call graph for this function:

◆ getCalledClass()

static ActiveRecord::getCalledClass ( )
staticprotected
Returns
ActiveRecord

Returns an instance of the instatiated calling active record (needs to be done in static methods) : This should be cached somehow

Definition at line 330 of file class.ActiveRecord.php.

References arCalledClassCache\get().

330  {
331  $class = get_called_class();
332 
333  return arCalledClassCache::get($class);
334  }
+ Here is the call graph for this function:

◆ getCollection()

static ActiveRecord::getCollection ( )
static
Returns
ActiveRecordList

Definition at line 789 of file class.ActiveRecord.php.

Referenced by arStorageRecordGUI\index().

789  {
790  $srModelObjectList = new ActiveRecordList(self::getCalledClass());
791 
792  return $srModelObjectList;
793  }
Class ActiveRecordList.
+ Here is the caller graph for this function:

◆ getConnectorContainerName()

ActiveRecord::getConnectorContainerName ( )
Returns
string Return the Name of your Connector Table

Definition at line 66 of file class.ActiveRecord.php.

References $connector_container_name.

Referenced by ActiveRecordList\__construct(), arWhere\asSQLStatement(), arJoin\asStatementText(), arConnectorDB\checkFieldExists(), arConnectorDB\checkTableExists(), arConnectorDB\create(), ActiveRecordList\innerjoinAR(), innerjoinAR(), arConnectorDB\installDatabase(), arConnectorDB\nextID(), arConnectorDB\read(), arConnectorDB\removeField(), arConnectorDB\renameField(), arConnectorDB\resetDatabase(), arConnectorDB\truncateDatabase(), arConnectorDB\update(), arConnectorDB\updateDatabase(), and arConnectorDB\updateIndices().

66  {
67  // WILL BE ABSTRACT TO REPLACE returnDbTableName() IN NEXT VERSION
68  if ($this->connector_container_name) {
70  } else {
71  $ar = self::getCalledClass();
72 
73  return $ar::returnDbTableName();
74  }
75  }
+ Here is the caller graph for this function:

◆ getFirstFromLastQuery()

static ActiveRecord::getFirstFromLastQuery ( )
static
Returns
ActiveRecordList
Deprecated:

Definition at line 810 of file class.ActiveRecord.php.

810  {
811  $srModelObjectList = new ActiveRecordList(self::getCalledClass());
812 
813  return $srModelObjectList->getFirstFromLastQuery();
814  }
Class ActiveRecordList.

◆ getPrimaryFieldValue()

ActiveRecord::getPrimaryFieldValue ( )
Returns
mixed

Definition at line 89 of file class.ActiveRecord.php.

References arFieldCache\getPrimaryFieldName().

Referenced by arConnectorSession\create(), arObjectCache\purge(), arConnectorSession\read(), arConnectorDB\read(), read(), arObjectCache\store(), store(), and arConnectorDB\update().

89  {
90  $primary_fieldname = arFieldCache::getPrimaryFieldName($this);
91 
92  return $this->{$primary_fieldname};
93  }
static getPrimaryFieldName(ActiveRecord $ar)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ innerjoin()

static ActiveRecord::innerjoin (   $tablename,
  $on_this,
  $on_external,
  $fields = array( '*' ),
  $operator = '=',
  $both_external = false 
)
static
Parameters
$tablename
$on_this
$on_external
array$fields
string$operator
Returns
$this

Definition at line 674 of file class.ActiveRecord.php.

674  {
675  $srModelObjectList = new ActiveRecordList(self::getCalledClass());
676 
677  return $srModelObjectList->innerjoin($tablename, $on_this, $on_external, $fields, $operator, $both_external);
678  }
Class ActiveRecordList.

◆ innerjoinAR()

static ActiveRecord::innerjoinAR ( ActiveRecord  $ar,
  $on_this,
  $on_external,
  $fields = array( '*' ),
  $operator = '=',
  $both_external = false 
)
static
Parameters
ActiveRecord$ar
$on_this
$on_external
array$fields
string$operator
Returns
$this

Definition at line 660 of file class.ActiveRecord.php.

References getConnectorContainerName().

660  {
661  return self::innerjoin($ar->getConnectorContainerName(), $on_this, $on_external, $fields, $operator, $both_external);
662  }
+ Here is the call graph for this function:

◆ installConnector()

ActiveRecord::installConnector ( )
Returns
bool
Deprecated:
Do not use in Core DB-update.

Definition at line 355 of file class.ActiveRecord.php.

References installDatabase().

355  {
356  return $this->installDatabase();
357  }
+ Here is the call graph for this function:

◆ installDatabase()

ActiveRecord::installDatabase ( )
finalprotected
Returns
bool

Definition at line 402 of file class.ActiveRecord.php.

References array, getArConnector(), getArFieldList(), and tableExists().

Referenced by installConnector().

402  {
403  if (!$this->tableExists()) {
404  $fields = array();
405  foreach ($this->getArFieldList()->getFields() as $field) {
406  $fields[$field->getName()] = $field->getAttributesForConnector();
407  }
408 
409  return $this->getArConnector()->installDatabase($this, $fields);
410  } else {
411  return $this->getArConnector()->updateDatabase($this);
412  }
413  }
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ installDB()

static ActiveRecord::installDB ( )
staticfinal
Returns
bool
Deprecated:
Do not use in Core DB-update. Please generate the manual installation script by using:
        $arBuilder = new arBuilder(new ilYourARBasedClass());
        $arBuilder->generateDBUpdateForInstallation();

Definition at line 345 of file class.ActiveRecord.php.

Referenced by arConnectorDB\resetDatabase().

345  {
346  return self::getCalledClass()->installDatabase();
347  }
+ Here is the caller graph for this function:

◆ last()

static ActiveRecord::last ( )
static
Returns
ActiveRecord

Definition at line 799 of file class.ActiveRecord.php.

799  {
800  $srModelObjectList = new ActiveRecordList(self::getCalledClass());
801 
802  return $srModelObjectList->last();
803  }
Class ActiveRecordList.

◆ leftjoin()

static ActiveRecord::leftjoin (   $tablename,
  $on_this,
  $on_external,
  $fields = array( '*' ),
  $operator = '=',
  $both_external = false 
)
static
Parameters
$tablename
$on_this
$on_external
array$fields
string$operator
Returns
$this

Definition at line 690 of file class.ActiveRecord.php.

690  {
691  $srModelObjectList = new ActiveRecordList(self::getCalledClass());
692 
693  return $srModelObjectList->leftjoin($tablename, $on_this, $on_external, $fields, $operator, $both_external);
694  }
Class ActiveRecordList.

◆ limit()

static ActiveRecord::limit (   $start,
  $end 
)
static
Parameters
$start
$end
Returns
ActiveRecordList

Definition at line 730 of file class.ActiveRecord.php.

References $start.

730  {
731  $srModelObjectList = new ActiveRecordList(self::getCalledClass());
732  $srModelObjectList->limit($start, $end);
733 
734  return $srModelObjectList;
735  }
Class ActiveRecordList.

◆ orderBy()

static ActiveRecord::orderBy (   $orderBy,
  $orderDirection = 'ASC' 
)
static
Parameters
$orderBy
string$orderDirection
Returns
ActiveRecordList

Definition at line 703 of file class.ActiveRecord.php.

Referenced by ilDclTableView\createOrGetStandardView(), and ilOrgUnitPathStorage\getTextRepresentationOfOrgUnits().

703  {
704  $srModelObjectList = new ActiveRecordList(self::getCalledClass());
705  $srModelObjectList->orderBy($orderBy, $orderDirection);
706 
707  return $srModelObjectList;
708  }
Class ActiveRecordList.
+ Here is the caller graph for this function:

◆ preloadObjects()

static ActiveRecord::preloadObjects ( )
static
Returns
ActiveRecord[]

Definition at line 545 of file class.ActiveRecord.php.

545  {
546  return self::get();
547  }

◆ raw()

static ActiveRecord::raw (   $set_raw = true)
static
Parameters
bool$set_raw
Returns
ActiveRecordList

Definition at line 834 of file class.ActiveRecord.php.

834  {
835  $srModelObjectList = new ActiveRecordList(self::getCalledClass());
836 
837  return $srModelObjectList->raw($set_raw);
838  }
Class ActiveRecordList.

◆ read()

ActiveRecord::read ( )

Definition at line 505 of file class.ActiveRecord.php.

References $records, afterObjectLoad(), count(), getArConnector(), getArrayForConnector(), getPrimaryFieldValue(), arException\RECORD_NOT_FOUND, arObjectCache\store(), and wakeUp().

Referenced by __construct().

505  {
506  $records = $this->getArConnector()->read($this);
507  if (count($records) == 0 AND $this->ar_safe_read == true) {
509  } elseif (count($records) == 0 AND $this->ar_safe_read == false) {
510  $this->is_new = true;
511  }
512  foreach ($records as $rec) {
513  foreach ($this->getArrayForConnector() as $k => $v) {
514  if ($this->wakeUp($k, $rec->{$k}) === null) {
515  $this->{$k} = $rec->{$k};
516  } else {
517  $this->{$k} = $this->wakeUp($k, $rec->{$k});
518  }
519  }
520  arObjectCache::store($this);
521  $this->afterObjectLoad();
522  }
523  }
$records
Definition: simple_test.php:22
static store(ActiveRecord $object)
wakeUp($field_name, $field_value)
Class arException.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeDBField()

static ActiveRecord::removeDBField (   $field_name)
staticfinal
Parameters
$field_name
Returns
bool

Definition at line 394 of file class.ActiveRecord.php.

394  {
395  return self::getCalledClass()->getArConnector()->removeField(self::getCalledClass(), $field_name);
396  }

◆ renameDBField()

static ActiveRecord::renameDBField (   $old_name,
  $new_name 
)
staticfinal
Parameters
$old_name
$new_name
Returns
bool

Definition at line 366 of file class.ActiveRecord.php.

366  {
367  return self::getCalledClass()->getArConnector()->renameField(self::getCalledClass(), $old_name, $new_name);
368  }

◆ resetDB()

static ActiveRecord::resetDB ( )
staticfinal
Returns
bool

Definition at line 433 of file class.ActiveRecord.php.

433  {
434  return self::getCalledClass()->getArConnector()->resetDatabase(self::getCalledClass());
435  }

◆ returnDbTableName()

static ActiveRecord::returnDbTableName ( )
static
Exceptions

Definition at line 57 of file class.ActiveRecord.php.

References arException\UNKNONWN_EXCEPTION.

57  {
58  throw new arException(arException::UNKNONWN_EXCEPTION, 'Implement getConnectorContainerName in your child-class');
59  }
const UNKNONWN_EXCEPTION
Class arException.

◆ save()

ActiveRecord::save ( )

Definition at line 468 of file class.ActiveRecord.php.

References store().

468  {
469  $this->store();
470  }
+ Here is the call graph for this function:

◆ serializeToCSV()

ActiveRecord::serializeToCSV (   $field)
protected

This method is called for every field of your instance if you use __asCsv.

You can use it to customize your export into csv. (e.g. serialize an array).

Parameters
$fieldstring
Returns
mixed

Definition at line 191 of file class.ActiveRecord.php.

Referenced by __asCsv().

191  {
192  return null;
193  }
+ Here is the caller graph for this function:

◆ setConnectorContainerName()

ActiveRecord::setConnectorContainerName (   $connector_container_name)
Parameters
string$connector_container_name

Definition at line 81 of file class.ActiveRecord.php.

References $connector_container_name.

81  {
82  $this->connector_container_name = $connector_container_name;
83  }

◆ setPrimaryFieldValue()

ActiveRecord::setPrimaryFieldValue (   $value)
Parameters
$value

Definition at line 99 of file class.ActiveRecord.php.

References arFieldCache\getPrimaryFieldName().

99  {
100  $primary_fieldname = arFieldCache::getPrimaryFieldName($this);
101 
102  $this->{$primary_fieldname} = $value;
103  }
static getPrimaryFieldName(ActiveRecord $ar)
+ Here is the call graph for this function:

◆ sleep()

ActiveRecord::sleep (   $field_name)
Parameters
$field_name
Returns
mixed

Definition at line 277 of file class.ActiveRecord.php.

Referenced by getArrayForConnector().

277  {
278  return null;
279  }
+ Here is the caller graph for this function:

◆ store()

ActiveRecord::store ( )

Definition at line 456 of file class.ActiveRecord.php.

References array, create(), arFieldCache\getPrimaryFieldName(), getPrimaryFieldValue(), and update().

Referenced by save().

456  {
457  $primary_fieldname = arFieldCache::getPrimaryFieldName($this);
458  $primary_value = $this->getPrimaryFieldValue();
459 
460  if (!self::where(array( $primary_fieldname => $primary_value ))->hasSets()) {
461  $this->create();
462  } else {
463  $this->update();
464  }
465  }
static getPrimaryFieldName(ActiveRecord $ar)
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ storeObjectToCache()

ActiveRecord::storeObjectToCache ( )

Definition at line 126 of file class.ActiveRecord.php.

References arObjectCache\store().

126  {
127  arObjectCache::store($this);
128  }
static store(ActiveRecord $object)
+ Here is the call graph for this function:

◆ tableExists()

static ActiveRecord::tableExists ( )
staticfinal
Returns
bool

Definition at line 374 of file class.ActiveRecord.php.

Referenced by installDatabase().

374  {
375  return self::getCalledClass()->getArConnector()->checkTableExists(self::getCalledClass());
376  }
+ Here is the caller graph for this function:

◆ truncateDB()

static ActiveRecord::truncateDB ( )
staticfinal
Returns
bool

Definition at line 441 of file class.ActiveRecord.php.

441  {
442  return self::getCalledClass()->getArConnector()->truncateDatabase(self::getCalledClass());
443  }

◆ update()

ActiveRecord::update ( )

Definition at line 526 of file class.ActiveRecord.php.

References getArConnector(), and arObjectCache\store().

Referenced by ilStudyProgrammeType\getAllTypesArray(), ilOrgUnitPathStorage\store(), and store().

526  {
527  $this->getArConnector()->update($this);
528  arObjectCache::store($this);
529  }
static store(ActiveRecord $object)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateDB()

static ActiveRecord::updateDB ( )
staticfinal
Returns
bool

Definition at line 419 of file class.ActiveRecord.php.

419  {
420  if (!self::tableExists()) {
421  self::getCalledClass()->installDatabase();
422 
423  return true;
424  }
425 
426  return self::getCalledClass()->getArConnector()->updateDatabase(self::getCalledClass());
427  }

◆ wakeUp()

ActiveRecord::wakeUp (   $field_name,
  $field_value 
)
Parameters
$field_name
$field_value
Returns
mixed

Definition at line 288 of file class.ActiveRecord.php.

Referenced by buildFromArray(), and read().

288  {
289  return null;
290  }
+ Here is the caller graph for this function:

◆ where()

static ActiveRecord::where (   $where,
  $operator = null 
)
static
Parameters
$where
null$operator
Returns
ActiveRecordList

Definition at line 643 of file class.ActiveRecord.php.

Referenced by ilStudyProgrammeUserProgress\__construct(), ilDclTableView\createFieldSetting(), ilStudyProgrammeType\getAllTypesArray(), ilStudyProgrammeType\getAssignedAdvancedMDRecords(), ilStudyProgrammeType\getAssignedStudyProgrammes(), ilObjStudyProgramme\getAssignmentsOf(), ilObjStudyProgramme\getAssignmentsRaw(), ilStudyProgrammeType\getAvailableAdvancedMDRecords(), ilDclCache\getFieldProperties(), ilDclTableView\getFieldSettings(), ilDclBaseFieldModel\getFieldSettings(), ilDclTableView\getFilterableFieldSettings(), ilStudyProgrammeUserProgress\getInstanceForAssignment(), ilStudyProgrammeUserProgress\getInstancesForAssignment(), ilStudyProgrammeUserAssignment\getInstancesForProgram(), ilStudyProgrammeUserProgress\getInstancesForProgram(), ilStudyProgrammeUserProgress\getInstancesForUser(), ilStudyProgrammeUserAssignment\getInstancesOfUser(), ilDclTableHelper\getStandardViewsByVisibleTables(), ilStudyProgrammeType\getTranslation(), ilStudyProgrammeType\getTranslations(), ilDclTableView\getVisibleFields(), ilStudyProgrammeType\loadTranslation(), ilDclCache\preloadFieldProperties(), and ilOrgUnitPathStorage\store().

643  {
644  $srModelObjectList = new ActiveRecordList(self::getCalledClass());
645  $srModelObjectList->where($where, $operator);
646 
647  return $srModelObjectList;
648  }
Class ActiveRecordList.
+ Here is the caller graph for this function:

Field Documentation

◆ $ar_safe_read

ActiveRecord::$ar_safe_read = true
protected

Definition at line 30 of file class.ActiveRecord.php.

◆ $connector_container_name

ActiveRecord::$connector_container_name = ''
protected

Definition at line 34 of file class.ActiveRecord.php.

Referenced by getConnectorContainerName(), and setConnectorContainerName().

◆ ACTIVE_RECORD_VERSION

const ActiveRecord::ACTIVE_RECORD_VERSION = '2.0.7'

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


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