ILIAS  release_8 Revision v8.24
ActiveRecord Class Reference

Class ActiveRecord. More...

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

Public Member Functions

 getArConnector ()
 
 getArFieldList ()
 
 getConnectorContainerName ()
 @description Return the Name of your Connector Table More...
 
 setConnectorContainerName (string $connector_container_name)
 
 getPrimaryFieldValue ()
 
 setPrimaryFieldValue ($value)
 
 __construct ($primary_key=0)
 
 storeObjectToCache ()
 
 asStdClass ()
 
 buildFromArray (array $array)
 
 fixDateField ($field_name, $value)
 
 sleep ($field_name)
 
 wakeUp ($field_name, $field_value)
 
 getArrayForConnector ()
 
 installConnector ()
 
 store ()
 
 save ()
 
 create ()
 
 copy (int $new_id=0)
 
 afterObjectLoad ()
 
 read ()
 
 update ()
 
 delete ()
 
 __call ($name, $arguments)
 

Static Public Member Functions

static returnDbTableName ()
 
static installDB ()
 
static renameDBField (string $old_name, string $new_name)
 
static tableExists ()
 
static fieldExists (string $field_name)
 
static removeDBField (string $field_name)
 
static updateDB ()
 
static resetDB ()
 
static truncateDB ()
 
static flushDB ()
 @depracated never use in ILIAS Core, Plugins only More...
 
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, array $fields=array(' *'), string $operator='=', $both_external=false)
 
static innerjoin ( $tablename, $on_this, $on_external, array $fields=array(' *'), string $operator='=', bool $both_external=false)
 
static leftjoin ( $tablename, $on_this, $on_external, array $fields=array(' *'), string $operator='=', bool $both_external=false)
 
static orderBy ($orderBy, string $orderDirection='ASC')
 
static dateFormat (string $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 (bool $set_raw=true)
 
static getArray (?string $key=null, $values=null)
 
static _toCamelCase (string $str, bool $capitalise_first_char=false)
 

Protected Member Functions

 installDatabase ()
 

Static Protected Member Functions

static getCalledClass ()
 @description Returns an instance of the instatiated calling active record (needs to be done in static methods) @TODO : This should be cached somehow More...
 
static fromCamelCase (string $str)
 

Protected Attributes

bool $ar_safe_read = true
 
string $connector_container_name = ''
 
bool $is_new = true
 

Detailed Description

Class ActiveRecord.

Author
Fabian Schmid fs@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch
Oskar Truffer ot@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch @experimental @description
Version
2.0.7

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

Constructor & Destructor Documentation

◆ __construct()

ActiveRecord::__construct (   $primary_key = 0)
Parameters
mixed$primary_key

Reimplemented in ilOrgUnitAuthority, and ilOrgUnitPermission.

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

96 {
97 $arFieldList = arFieldCache::get($this);
98
99 $key = $arFieldList->getPrimaryFieldName();
100 $this->{$key} = $primary_key;
101 if ($primary_key !== 0 && $primary_key !== null && $primary_key !== false) {
102 $this->read();
103 }
104 }
static get(ActiveRecord $ar)
string $key
Consumer key/client ID value.
Definition: System.php:193

References ILIAS\LTI\ToolProvider\$key, arFieldCache\get(), and read().

+ Here is the call graph for this function:

Member Function Documentation

◆ __call()

ActiveRecord::__call (   $name,
  $arguments 
)
Parameters
$name
$arguments
Returns
mixed @noinspection PhpInconsistentReturnPointsInspection since this a dynamic call

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

673 {
674 // Getter
675 if (preg_match("/get([a-zA-Z]*)/u", $name, $matches) && count($arguments) === 0) {
676 return $this->{self::fromCamelCase($matches[1])};
677 }
678 // Setter
679 if (preg_match("/set([a-zA-Z]*)/u", $name, $matches) && count($arguments) === 1) {
680 $this->{self::fromCamelCase($matches[1])} = $arguments[0];
681 }
682 }
static fromCamelCase(string $str)
if($format !==null) $name
Definition: metadata.php:247

References $name.

◆ _toCamelCase()

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

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

684 : ?string
685 {
686 if ($capitalise_first_char) {
687 $str[0] = strtoupper($str[0]);
688 }
689
690 return preg_replace_callback('/_([a-z])/', fn ($c) => strtoupper($c[1]), $str);
691 }
$c
Definition: cli.php:38

References $c.

◆ additionalParams()

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

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

404 {
405 $srModelObjectList = new ActiveRecordList(self::getCalledClass());
406 $srModelObjectList->additionalParams($additional_params);
407
408 return $srModelObjectList;
409 }
@noinspection NullPointerExceptionInspection

◆ affectedRows()

static ActiveRecord::affectedRows ( )
static

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

580 : int
581 {
582 $srModelObjectList = new ActiveRecordList(self::getCalledClass());
583
584 return $srModelObjectList->affectedRows();
585 }

◆ afterObjectLoad()

ActiveRecord::afterObjectLoad ( )

Reimplemented in ilDclFieldProperty, ilOrgUnitPosition, ilOrgUnitPermission, and CachedActiveRecord.

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

350 : void
351 {
352 }

◆ asStdClass()

ActiveRecord::asStdClass ( )

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

111 : \stdClass
112 {
113 $return = new stdClass();
114 foreach ($this->getArFieldList()->getFields() as $field) {
115 $fieldname = $field->getName();
116 $return->{$fieldname} = $this->{$fieldname};
117 }
118
119 return $return;
120 }

References getArFieldList().

Referenced by arConnectorSession\create(), and arConnectorCache\storeActiveRecordInCache().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildFromArray()

ActiveRecord::buildFromArray ( array  $array)

Reimplemented in ilAccessibilityDocument, and ilTermsOfServiceDocument.

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

123 {
124 $class = get_class($this);
125 $primary = $this->getArFieldList()->getPrimaryFieldName();
126 $primary_value = $array[$primary];
127 if ($primary_value && arObjectCache::isCached($class, $primary_value)) {
128 return arObjectCache::get($class, $primary_value);
129 }
130 foreach ($array as $field_name => $value) {
131 $waked = $this->wakeUp($field_name, $value);
132 $this->{$field_name} = $waked ?? $value;
133 }
135
136 return $this;
137 }
Class ActiveRecord.
wakeUp($field_name, $field_value)
static isCached($class, $id)
static store(ActiveRecord $object)
static get($class, $id)

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

+ Here is the call graph for this function:

◆ connector()

static ActiveRecord::connector ( arConnector  $connector)
static

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

640 {
641 $srModelObjectList = new ActiveRecordList(self::getCalledClass());
642
643 return $srModelObjectList->connector($connector);
644 }

◆ copy()

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

Reimplemented in CachedActiveRecord.

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

339 : self
340 {
341 if (self::where(array($this->getArFieldList()->getPrimaryFieldName() => $new_id))->hasSets()) {
343 }
344 $new_obj = clone($this);
345 $new_obj->setPrimaryFieldValue($new_id);
346
347 return $new_obj;
348 }
Class arException.
const COPY_DESTINATION_ID_EXISTS

References arException\COPY_DESTINATION_ID_EXISTS.

◆ count()

static ActiveRecord::count ( )
static

◆ create()

ActiveRecord::create ( )

Reimplemented in ilDclFieldProperty, ilOrgUnitPosition, ilOrgUnitOperation, ilOrgUnitOperationContext, ilOrgUnitPermission, ilOrgUnitUserAssignment, ilAccessibilityDocumentCriterionAssignment, CachedActiveRecord, ilADNNotification, ilMMItemStorage, ilTermsOfServiceDocumentCriterionAssignment, and ilTermsOfServiceDocument.

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

325 : void
326 {
327 if ($this->getArFieldList()->getPrimaryField()->getSequence()) {
328 $primary_fieldname = arFieldCache::getPrimaryFieldName($this);
329 $this->{$primary_fieldname} = $this->getArConnector()->nextID($this);
330 }
331
332 $this->getArConnector()->create($this);
334 }
static getPrimaryFieldName(ActiveRecord $ar)

References arFieldCache\getPrimaryFieldName(), and arObjectCache\store().

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dateFormat()

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

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

560 :i:s'): \ActiveRecordList
561 {
562 $srModelObjectList = new ActiveRecordList(self::getCalledClass());
563 $srModelObjectList->dateFormat($date_format);
564
565 return $srModelObjectList;
566 }

◆ debug()

static ActiveRecord::debug ( )
static

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

603 {
604 $srModelObjectList = new ActiveRecordList(self::getCalledClass());
605
606 return $srModelObjectList->debug();
607 }

◆ delete()

ActiveRecord::delete ( )

Reimplemented in ilDclTableView, ilOrgUnitPosition, ilOrgUnitPermission, ilOrgUnitUserAssignment, CachedActiveRecord, and ilTermsOfServiceDocument.

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

382 {
383 $this->getArConnector()->delete($this);
385 }
static purge(ActiveRecord $object)

References arObjectCache\purge().

+ Here is the call graph for this function:

◆ fieldExists()

static ActiveRecord::fieldExists ( string  $field_name)
staticfinal
Parameters
$field_name

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

238 : bool
239 {
240 return self::getCalledClass()->getArConnector()->checkFieldExists(self::getCalledClass(), $field_name);
241 }
static getCalledClass()
@description Returns an instance of the instatiated calling active record (needs to be done in static...

◆ 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
Exceptions
arException

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

446 {
447 $obj = self::find($primary_key, $add_constructor_args);
448 if (is_null($obj)) {
450 }
451
452 return $obj;
453 }

References arException\RECORD_NOT_FOUND.

Referenced by ilSecurePathDefinitionProcessor\beginTag(), ilBiblLibraryFactory\findById(), ilBiblFieldFilterFactory\findById(), ilBiblTranslationFactory\findById(), ilOrgUnitOperationQueries\findById(), and ilADNNotificationGUI\getNotificationFromRequest().

+ Here is the caller graph for this function:

◆ findOrGetInstance()

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

Reimplemented in ilDclTableView.

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

461 {
462 $obj = self::find($primary_key, $add_constructor_args);
463 if ($obj !== null) {
464 return $obj;
465 }
466
467 $class_name = static::class;
468 $obj = arFactory::getInstance($class_name, 0, $add_constructor_args);
469 $obj->setPrimaryFieldValue($primary_key);
470 $obj->is_new = true;
471 $obj->storeObjectToCache();
472
473 return $obj;
474 }

◆ first()

static ActiveRecord::first ( )
static

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

610 {
611 $srModelObjectList = new ActiveRecordList(self::getCalledClass());
612
613 return $srModelObjectList->first();
614 }

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

+ Here is the caller graph for this function:

◆ fixDateField()

ActiveRecord::fixDateField (   $field_name,
  $value 
)
Parameters
$field_name
$value
Returns
string|mixed @noinspection NullPointerExceptionInspection

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

146 {
147 if ($this->getArFieldList()->getFieldByName($field_name)->isDateField()) {
148 return $this->getArConnector()->fixDate($value);
149 }
150
151 return $value;
152 }

◆ flushDB()

static ActiveRecord::flushDB ( )
staticfinal

@depracated never use in ILIAS Core, Plugins only

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

300 : void
301 {
303 }

Referenced by ilMMTopItemGUI\restore().

+ Here is the caller graph for this function:

◆ fromCamelCase()

static ActiveRecord::fromCamelCase ( string  $str)
staticprotected

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

693 : ?string
694 {
695 $str[0] = strtolower($str[0]);
696
697 return preg_replace_callback('/([A-Z])/', fn ($c) => "_" . strtolower($c[1]), $str);
698 }

References $c.

◆ get()

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

Reimplemented in ilOrgUnitPosition.

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

595 : array
596 {
597 $srModelObjectList = new ActiveRecordList(self::getCalledClass());
598
599 return $srModelObjectList->get();
600 }

Referenced by ilGlobalCacheMetricsCollectedObjective\collectFrom(), and ilBiblLibraryFactory\getAll().

+ Here is the caller graph for this function:

◆ getArConnector()

ActiveRecord::getArConnector ( )

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

31 {
32 return arConnectorMap::get($this);
33 }
static get(ActiveRecord $ar)
Class arConnector.

References arConnectorMap\get().

Referenced by arWhere\asSQLStatement().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getArFieldList()

ActiveRecord::getArFieldList ( )

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

36 {
37 return arFieldCache::get($this);
38 }
Class arFieldList.

References arFieldCache\get().

Referenced by arWhere\asSQLStatement(), asStdClass(), CachedActiveRecord\buildHash(), CachedActiveRecord\getCacheIdentifier(), arConnectorDB\installDatabase(), arConnectorDB\updateDatabase(), and arConnectorDB\updateIndices().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getArray()

static ActiveRecord::getArray ( ?string  $key = null,
  $values = null 
)
static

◆ getArrayForConnector()

ActiveRecord::getArrayForConnector ( )
final

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

173 : array
174 {
175 $data = array();
176 foreach ($this->getArFieldList()->getFields() as $field) {
177 $field_name = $field->getName();
178 $sleeped = $this->sleep($field_name);
179 $var = $sleeped ?? ($this->{$field_name});
180 $data[$field_name] = array($field->getFieldType(), $var);
181 }
182
183 return $data;
184 }
sleep($field_name)

References $data.

Referenced by arConnectorDB\create(), and arConnectorDB\update().

+ Here is the caller graph for this function:

◆ getCalledClass()

static ActiveRecord::getCalledClass ( )
staticprotected

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

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

197 {
198 $class = static::class;
199
200 return arCalledClassCache::get($class);
201 }
static get(string $class_name)

References arCalledClassCache\get().

Referenced by getConnectorContainerName().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCollection()

static ActiveRecord::getCollection ( )
static

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

617 {
618 return new ActiveRecordList(self::getCalledClass());
619 ;
620 }

Referenced by ilDclTableViewEditGUI\executeCommand(), and ilBiblFieldFactory\getCollectionForFilter().

+ Here is the caller graph for this function:

◆ getConnectorContainerName()

ActiveRecord::getConnectorContainerName ( )

◆ getFirstFromLastQuery()

static ActiveRecord::getFirstFromLastQuery ( )
static
Deprecated:

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

633 {
634 $srModelObjectList = new ActiveRecordList(self::getCalledClass());
635
636 return $srModelObjectList->getFirstFromLastQuery();
637 }

◆ getPrimaryFieldValue()

ActiveRecord::getPrimaryFieldValue ( )
Returns
mixed

Reimplemented in ilADTActiveRecordWrapper.

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

76 {
77 $primary_fieldname = arFieldCache::getPrimaryFieldName($this);
78
79 return $this->{$primary_fieldname};
80 }

References arFieldCache\getPrimaryFieldName().

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

+ 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,
array  $fields = array('*'),
string  $operator = '=',
bool  $both_external = false 
)
static
Parameters
$tablename
$on_this
$on_external
Returns
$this

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

525 $srModelObjectList = new ActiveRecordList(self::getCalledClass());
526
527 return $srModelObjectList->innerjoin($tablename, $on_this, $on_external, $fields, $operator, $both_external);
528 }

Referenced by ilMStListCoursesTableGUI\fillRow(), and ilMStShowUserCoursesTableGUI\fillRow().

+ Here is the caller graph for this function:

◆ innerjoinAR()

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

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

501 return self::innerjoin(
503 $on_this,
504 $on_external,
505 $fields,
506 $operator,
507 $both_external
508 );
509 }
getConnectorContainerName()
@description Return the Name of your Connector Table
static innerjoin( $tablename, $on_this, $on_external, array $fields=array(' *'), string $operator='=', bool $both_external=false)

◆ installConnector()

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

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

216 : bool
217 {
218 return $this->installDatabase();
219 }

◆ installDatabase()

ActiveRecord::installDatabase ( )
finalprotected
Deprecated:
never use in ILIAS Core, Plugins only

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

253 : bool
254 {
255 if (!self::tableExists()) {
256 $fields = array();
257 if (isset($this)) {
258 foreach ($this->getArFieldList()->getFields() as $field) {
259 $fields[$field->getName()] = $field->getAttributesForConnector();
260 }
261 }
262
263 return $this->getArConnector()->installDatabase($this, $fields);
264 }
265
266 return $this->getArConnector()->updateDatabase($this);
267 }

◆ installDB()

static ActiveRecord::installDB ( )
staticfinal
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 208 of file class.ActiveRecord.php.

208 : bool
209 {
210 return self::getCalledClass()->installDatabase();
211 }

Referenced by arConnectorDB\resetDatabase().

+ Here is the caller graph for this function:

◆ last()

static ActiveRecord::last ( )
static

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

623 {
624 $srModelObjectList = new ActiveRecordList(self::getCalledClass());
625
626 return $srModelObjectList->last();
627 }

◆ leftjoin()

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

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

544 $srModelObjectList = new ActiveRecordList(self::getCalledClass());
545
546 return $srModelObjectList->leftjoin($tablename, $on_this, $on_external, $fields, $operator, $both_external);
547 }

◆ limit()

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

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

573 {
574 $srModelObjectList = new ActiveRecordList(self::getCalledClass());
575 $srModelObjectList->limit($start, $end);
576
577 return $srModelObjectList;
578 }

◆ orderBy()

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

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

553 {
554 $srModelObjectList = new ActiveRecordList(self::getCalledClass());
555 $srModelObjectList->orderBy($orderBy, $orderDirection);
556
557 return $srModelObjectList;
558 }

Referenced by ilDclTableView\createOrGetStandardView(), ilAccessibilityDocumentTableDataProvider\getList(), ilTermsOfServiceDocumentTableDataProvider\getList(), ilOrgUnitPathStorage\getTextRepresentationOfOrgUnits(), ilDclSelectionOption\getValues(), ilInitialisation\initAccessibilityControlConcept(), and ilInitialisation\initTermsOfService().

+ Here is the caller graph for this function:

◆ preloadObjects()

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

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

395 : array
396 {
397 return self::get();
398 }

References ILIAS\Repository\get().

+ Here is the call graph for this function:

◆ raw()

static ActiveRecord::raw ( bool  $set_raw = true)
static

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

647 {
648 $srModelObjectList = new ActiveRecordList(self::getCalledClass());
649
650 return $srModelObjectList->raw($set_raw);
651 }

◆ read()

ActiveRecord::read ( )
Exceptions
arException

Reimplemented in ilAccessibilityDocument, CachedActiveRecord, and ilTermsOfServiceDocument.

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

357 : void
358 {
359 $records = $this->getArConnector()->read($this);
360 if ($this->ar_safe_read === true && is_array($records) && count($records) === 0) {
362 } elseif ($this->ar_safe_read === false && is_array($records) && count($records) === 0) {
363 $this->is_new = true;
364 }
365 $records = is_array($records) ? $records : array();
366 foreach ($records as $rec) {
367 foreach ($this->getArrayForConnector() as $k => $v) {
368 $waked = $this->wakeUp($k, $rec->{$k} ?? null);
369 $this->{$k} = $waked ?? $rec->{$k} ?? null;
370 }
372 }
373 }

References arException\RECORD_NOT_FOUND.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ removeDBField()

static ActiveRecord::removeDBField ( string  $field_name)
staticfinal
Deprecated:
never use in ILIAS Core, Plugins only

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

246 : bool
247 {
248 return self::getCalledClass()->getArConnector()->removeField(self::getCalledClass(), $field_name);
249 }

◆ renameDBField()

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

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

225 : bool
226 {
227 return self::getCalledClass()->getArConnector()->renameField(self::getCalledClass(), $old_name, $new_name);
228 }

◆ resetDB()

static ActiveRecord::resetDB ( )
staticfinal
Deprecated:
never use in ILIAS Core, Plugins only

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

285 : bool
286 {
287 return self::getCalledClass()->getArConnector()->resetDatabase(self::getCalledClass());
288 }

◆ returnDbTableName()

◆ save()

ActiveRecord::save ( )

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

320 : void
321 {
322 $this->store();
323 }

◆ setConnectorContainerName()

ActiveRecord::setConnectorContainerName ( string  $connector_container_name)

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

67 : void
68 {
69 $this->connector_container_name = $connector_container_name;
70 }

References $connector_container_name.

◆ setPrimaryFieldValue()

ActiveRecord::setPrimaryFieldValue (   $value)
Parameters
$value

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

85 : void
86 {
87 $primary_fieldname = arFieldCache::getPrimaryFieldName($this);
88
89 $this->{$primary_fieldname} = $value;
90 }

References arFieldCache\getPrimaryFieldName().

+ Here is the call graph for this function:

◆ sleep()

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

Reimplemented in ilDclTableView, ilDclTableViewFieldSetting, ilOrgUnitPermission, and ilADTActiveRecordWrapper.

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

159 {
160 return null;
161 }

◆ store()

ActiveRecord::store ( )

Reimplemented in ilOrgUnitPathStorage.

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

308 : void
309 {
310 $primary_fieldname = arFieldCache::getPrimaryFieldName($this);
311 $primary_value = $this->getPrimaryFieldValue();
312
313 if (!self::where(array($primary_fieldname => $primary_value))->hasSets()) {
314 $this->create();
315 } else {
316 $this->update();
317 }
318 }

References arFieldCache\getPrimaryFieldName().

+ Here is the call graph for this function:

◆ storeObjectToCache()

ActiveRecord::storeObjectToCache ( )

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

106 : void
107 {
109 }

References arObjectCache\store().

+ Here is the call graph for this function:

◆ tableExists()

static ActiveRecord::tableExists ( )
staticfinal

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

230 : bool
231 {
232 return self::getCalledClass()->getArConnector()->checkTableExists(self::getCalledClass());
233 }

◆ truncateDB()

static ActiveRecord::truncateDB ( )
staticfinal
Deprecated:
never use in ILIAS Core, Plugins only

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

293 : void
294 {
295 self::getCalledClass()->getArConnector()->truncateDatabase(self::getCalledClass());
296 }

◆ update()

ActiveRecord::update ( )

Reimplemented in ilDclFieldProperty, ilOrgUnitPosition, ilOrgUnitPermission, ilAccessibilityDocumentCriterionAssignment, CachedActiveRecord, ilTermsOfServiceDocumentCriterionAssignment, and ilTermsOfServiceDocument.

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

376 {
377 $this->getArConnector()->update($this);
379 }

References arObjectCache\store().

Referenced by ilAccessibilityDocumentGUI\detachCriterionAssignment(), and ilOrgUnitPathStorage\store().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateDB()

static ActiveRecord::updateDB ( )
staticfinal
Deprecated:
never use in ILIAS Core, Plugins only

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

272 : bool
273 {
274 if (!self::tableExists()) {
275 self::getCalledClass()->installDatabase();
276
277 return true;
278 }
279
280 return self::getCalledClass()->getArConnector()->updateDatabase(self::getCalledClass());
281 }

◆ wakeUp()

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

Reimplemented in ilDclTableView, ilDclTableViewFieldSetting, ilOrgUnitPermission, ilADNNotification, and ilADTActiveRecordWrapper.

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

169 {
170 return null;
171 }

◆ where()

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

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

481 {
482 $srModelObjectList = new ActiveRecordList(self::getCalledClass());
483 $srModelObjectList->where($where, $operator);
484
485 return $srModelObjectList;
486 }

Referenced by ilOrgUnitPosition\afterObjectLoad(), ilDclTableView\createFieldSetting(), ilObjOrgUnit\delete(), ilMMAbstractItemFacade\deleteAssociatedTranslations(), ilBiblEntryFactory\deleteEntryById(), ilBiblFieldFilterFactory\filterItemsForTable(), OrgUnit\Positions\UserAssignment\ilOrgUnitUserAssignmentRepository\findAllUserAssingmentsByUserIds(), ilBiblFieldFilterFactory\findByFieldId(), ilBiblEntryFactory\findByIdAndTypeString(), ilOrgUnitOperationContextQueries\findByName(), ilOrgUnitOperationQueries\findByOperationString(), ilOrgUnitUserAssignment\findOrCreateAssignment(), OrgUnit\Positions\UserAssignment\ilOrgUnitUserAssignmentRepository\findOrCreateAssignment(), ilBiblFieldFactory\findOrCreateFieldOfAttribute(), ilBiblEntryFactory\getAllAttributesByEntryId(), ilDclSelectionOption\getAllForField(), ilBiblFieldFilterFactory\getAllForObjectId(), ilDclTableView\getAllForTableId(), ilBiblEntryFactory\getARInstance(), ilBiblFieldFactory\getARInstance(), ilObjOrgUnitTree\getAssignements(), ilOrgUnitUserAssignmentQueries\getAssignmentOrFail(), OrgUnit\Positions\UserAssignment\ilOrgUnitUserAssignmentRepository\getAssignmentOrFail(), ilOrgUnitUserAssignmentQueries\getAssignmentsOfUserId(), OrgUnit\Positions\UserAssignment\ilOrgUnitUserAssignmentRepository\getAssignmentsOfUserId(), ilOrgUnitUserAssignmentQueries\getAssignmentsOfUserIdAndPosition(), ilBiblAttributeFactory\getAttributesForEntry(), ILIAS\BackgroundTasks\Implementation\Persistence\BasicPersistence\getBucketIdsByState(), ILIAS\BackgroundTasks\Implementation\Persistence\BasicPersistence\getBucketIdsOfUser(), ILIAS\BackgroundTasks\Implementation\Persistence\BasicPersistence\getBucketMetaOfUser(), ilBiblFieldFilterFactory\getByObjectIdAndField(), ilBiblTranslationFactory\getCollectionOfTranslationsForField(), ilOrgUnitPosition\getCorePosition(), ilDclTableView\getCountForTableId(), ilOrgUnitPosition\getDependentAuthorities(), ilAccessibilityDocumentGUI\getDocumentsByServerRequest(), ilTermsOfServiceDocumentGUI\getDocumentsByServerRequest(), ilDclCache\getFieldProperties(), ilDclTableView\getFieldSetting(), ilDclTableView\getFieldSettings(), ilDclTableView\getFilterableFieldSettings(), ilBiblDataFactory\getIlBiblDataById(), ilDclTableFieldSetting\getInstance(), ilOrgUnitOperationQueries\getOperationsForContextId(), ilOrgUnitOperationQueries\getOperationsForContextName(), ilOrgUnitUserAssignmentQueries\getOrgUnitIdsOfUsersPosition(), ilDclTableHelper\getStandardViewsByVisibleTables(), ilOrgUnitPermissionQueries\getTemplateSetForContextName(), ilMMItemRepository\getTopItems(), ilOrgUnitUserAssignmentQueries\getUserAssignmentsOfPosition(), OrgUnit\Positions\UserAssignment\ilOrgUnitUserAssignmentRepository\getUserAssignmentsOfPosition(), ilOrgUnitUserAssignmentQueries\getUserIdsOfOrgUnit(), OrgUnit\Positions\UserAssignment\ilOrgUnitUserAssignmentRepository\getUserIdsOfOrgUnit(), ilOrgUnitUserAssignmentQueries\getUserIdsOfOrgUnits(), OrgUnit\Positions\UserAssignment\ilOrgUnitUserAssignmentRepository\getUserIdsOfOrgUnits(), ilOrgUnitUserAssignmentQueries\getUserIdsOfOrgUnitsInPosition(), OrgUnit\Positions\UserAssignment\ilOrgUnitUserAssignmentRepository\getUserIdsOfOrgUnitsInPosition(), ilOrgUnitUserAssignmentQueries\getUserIdsOfOrgUnitsOfUsersPosition(), OrgUnit\Positions\UserAssignment\ilOrgUnitUserAssignmentRepository\getUserIdsOfOrgUnitsOfUsersPosition(), ilOrgUnitUserAssignmentQueries\getUserIdsOfPosition(), OrgUnit\Positions\UserAssignment\ilOrgUnitUserAssignmentRepository\getUserIdsOfPosition(), ilDclBaseFieldModel\getViewSettings(), ilDclTableView\getVisibleFields(), ilADNDismiss\hasDimissed(), ilOrgUnitPermissionQueries\hasLocalSet(), ilBiblEntryFactory\loadParsedAttributesByEntryId(), ilMMItemTranslationTableGUI\parseData(), ilDclCache\preloadFieldProperties(), ilOrgUnitOperationContextQueries\registerNewContext(), ilADNNotification\resetForAllUsers(), ILIAS\OrgUnit\Webservices\SOAP\RemoveUserIdFromPositionInOrgUnit\run(), ilObjTermsOfServiceGUI\showMissingDocuments(), ilOrgUnitSimpleUserImport\simpleUserImportElement(), and ilOrgUnitPosition\storeAuthorities().

+ Here is the caller graph for this function:

Field Documentation

◆ $ar_safe_read

bool ActiveRecord::$ar_safe_read = true
protected

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

◆ $connector_container_name

string ActiveRecord::$connector_container_name = ''
protected

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

Referenced by getConnectorContainerName(), and setConnectorContainerName().

◆ $is_new

bool ActiveRecord::$is_new = true
protected

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


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