ILIAS  trunk Revision v11.0_alpha-1866-gfa368f7776e
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ActiveRecord Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

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

Public Member Functions

 getArConnector ()
 
 getArFieldList ()
 
 getConnectorContainerName ()
 Return the Name of your Connector Table More...
 
 setConnectorContainerName (string $connector_container_name)
 
 getPrimaryFieldValue ()
 
 setPrimaryFieldValue ($value)
 
 __construct (mixed $primary_key=0)
 
 storeObjectToCache ()
 
 asStdClass ()
 
 asArray ()
 
 buildFromArray (array $array)
 
 fixDateField ($field_name, string $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 ()
 never use in ILIAS Core, Plugins only More...
 
static preloadObjects ()
 
static additionalParams (array $additional_params)
 
static findOrFail ($primary_key, array $add_constructor_args=[])
 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=[])
 
static where ($where, $operator=null)
 
static innerjoinAR (ActiveRecord $activeRecord, $on_this, string $on_external, array $fields=[' *'], string $operator='=', bool $both_external=false)
 
static innerjoin (string $tablename, $on_this, string $on_external, array $fields=[' *'], string $operator='=', bool $both_external=false)
 
static leftjoin (string $tablename, $on_this, string $on_external, array $fields=[' *'], string $operator='=', bool $both_external=false)
 
static orderBy (string $orderBy, string $orderDirection='ASC')
 
static dateFormat (string $date_format='d.m.Y - H:i:s')
 
static limit (int $start, int $end)
 
static affectedRows ()
 
static count ()
 
static get ()
 
static debug ()
 
static first ()
 
static getCollection ()
 
static last ()
 
static getFirstFromLastQuery ()
 
static connector (arConnector $arConnector)
 
static raw (bool $set_raw=true)
 
static getArray (?string $key=null, string|array|null $values=null)
 
static _toCamelCase (string $str, bool $capitalise_first_char=false)
 

Protected Member Functions

 installDatabase ()
 

Static Protected Member Functions

static getCalledClass ()
 Returns an instance of the instatiated calling active record (needs to be done in static methods) : 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

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning This service is now deprecated and will be removed with ILIAS 12 or 13 (depending on how quickly users can replace their implementations). The ActiveRecord was a simple way of handling database operations and object mapping in its day. However, the pattern is not very lightweight and has a very large overhead. It also leads to many database queries and high memory consumption. For several releases now, the “Repository Pattern” has been propagated as a better alternative.

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

Constructor & Destructor Documentation

◆ __construct()

ActiveRecord::__construct ( mixed  $primary_key = 0)

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

References arFieldCache\get(), null, and read().

97  {
98  $arFieldList = arFieldCache::get($this);
99 
100  $primaryFieldName = $arFieldList->getPrimaryFieldName();
101  $this->{$primaryFieldName} = $primary_key;
102  if ($primary_key === 0) {
103  return;
104  }
105  if ($primary_key === null) {
106  return;
107  }
108  if ($primary_key === false) {
109  return;
110  }
111  $this->read();
112  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static get(ActiveRecord $activeRecord)
+ Here is the call graph for this function:

Member Function Documentation

◆ __call()

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

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

References count(), and null.

701  {
702  // Getter
703  if (preg_match("/get([a-zA-Z]*)/u", (string) $name, $matches) && (is_countable($arguments) ? count(
704  $arguments
705  ) : 0) === 0) {
706  return $this->{self::fromCamelCase($matches[1])};
707  }
708  // Setter
709  if (!preg_match("/set([a-zA-Z]*)/u", (string) $name, $matches)) {
710  return null;
711  }
712  if (count($arguments) !== 1) {
713  return null;
714  }
715  $this->{self::fromCamelCase($matches[1])} = $arguments[0];
716  return null;
717  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:

◆ _toCamelCase()

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

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

References $c.

719  : ?string
720  {
721  if ($capitalise_first_char) {
722  $str[0] = strtoupper($str[0]);
723  }
724 
725  return preg_replace_callback('/_([a-z])/', fn($c): string => strtoupper($c[1]), $str);
726  }
$c
Definition: deliver.php:25

◆ additionalParams()

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

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

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

431  {
432  $activeRecordList = new ActiveRecordList(self::getCalledClass());
433  $activeRecordList->additionalParams($additional_params);
434 
435  return $activeRecordList;
436  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ affectedRows()

static ActiveRecord::affectedRows ( )
static

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

607  : int
608  {
609  $activeRecordList = new ActiveRecordList(self::getCalledClass());
610 
611  return $activeRecordList->affectedRows();
612  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ afterObjectLoad()

ActiveRecord::afterObjectLoad ( )

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

376  : void
377  {
378  }

◆ asArray()

ActiveRecord::asArray ( )
Returns
array<string, mixed>

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

References getArFieldList().

Referenced by arConnectorCache\storeActiveRecordInCache().

133  : array
134  {
135  $return = [];
136  foreach ($this->getArFieldList()->getFields() as $arField) {
137  $fieldname = $arField->getName();
138  $return[$fieldname] = $this->{$fieldname};
139  }
140 
141  return $return;
142  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ asStdClass()

ActiveRecord::asStdClass ( )

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

References getArFieldList().

Referenced by arConnectorSession\create().

119  : \stdClass
120  {
121  $return = new stdClass();
122  foreach ($this->getArFieldList()->getFields() as $arField) {
123  $fieldname = $arField->getName();
124  $return->{$fieldname} = $this->{$fieldname};
125  }
126 
127  return $return;
128  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildFromArray()

ActiveRecord::buildFromArray ( array  $array)

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

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

144  : static
145  {
146  $class = static::class;
147  $primary = $this->getArFieldList()->getPrimaryFieldName();
148  $primary_value = $array[$primary];
149  if ($primary_value && arObjectCache::isCached($class, $primary_value)) {
150  return arObjectCache::get($class, $primary_value);
151  }
152  foreach ($array as $field_name => $value) {
153  $waked = $this->wakeUp($field_name, $value);
154  $this->{$field_name} = $waked ?? $value;
155  }
156  arObjectCache::store($this);
157 
158  return $this;
159  }
static get(string $class, string $id)
wakeUp($field_name, $field_value)
static store(ActiveRecord $activeRecord)
static isCached($class, $id)
+ Here is the call graph for this function:

◆ connector()

static ActiveRecord::connector ( arConnector  $arConnector)
static

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

667  {
668  $activeRecordList = new ActiveRecordList(self::getCalledClass());
669 
670  return $activeRecordList->connector($arConnector);
671  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ copy()

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

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

References arException\COPY_DESTINATION_ID_EXISTS, and getArFieldList().

365  : self
366  {
367  if (self::where([$this->getArFieldList()->getPrimaryFieldName() => $new_id])->hasSets()) {
369  }
370  $new_obj = clone($this);
371  $new_obj->setPrimaryFieldValue($new_id);
372 
373  return $new_obj;
374  }
const COPY_DESTINATION_ID_EXISTS
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ count()

static ActiveRecord::count ( )
static

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

Referenced by __call(), ilAccessibilityDocument\buildFromArray(), ilAccessibilityDocument\detachCriterion(), and ilOrgUnitPathStorage\getTextRepresentationOfOrgUnits().

614  : int
615  {
616  return self::affectedRows();
617  }
+ Here is the caller graph for this function:

◆ create()

ActiveRecord::create ( )

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

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

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

351  : void
352  {
353  if ($this->getArFieldList()->getPrimaryField()->getSequence()) {
354  $primary_fieldname = arFieldCache::getPrimaryFieldName($this);
355  $this->{$primary_fieldname} = $this->getArConnector()->nextID($this);
356  }
357 
358  $this->getArConnector()->create($this);
359  arObjectCache::store($this);
360  }
static getPrimaryFieldName(ActiveRecord $activeRecord)
static store(ActiveRecord $activeRecord)
+ 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 587 of file class.ActiveRecord.php.

587  :i:s'): \ActiveRecordList
588  {
589  $activeRecordList = new ActiveRecordList(self::getCalledClass());
590  $activeRecordList->dateFormat($date_format);
591 
592  return $activeRecordList;
593  }

◆ debug()

static ActiveRecord::debug ( )
static

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

630  {
631  $activeRecordList = new ActiveRecordList(self::getCalledClass());
632 
633  return $activeRecordList->debug();
634  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ delete()

ActiveRecord::delete ( )

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

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

Referenced by ILIAS\BackgroundTasks\Implementation\Persistence\BasicPersistence\getValueContainerId().

408  : void
409  {
410  $this->getArConnector()->delete($this);
411  arObjectCache::purge($this);
412  }
static purge(ActiveRecord $activeRecord)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fieldExists()

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

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

263  : bool
264  {
265  return self::getCalledClass()->getArConnector()->checkFieldExists(self::getCalledClass(), $field_name);
266  }

◆ findOrFail()

static ActiveRecord::findOrFail (   $primary_key,
array  $add_constructor_args = [] 
)
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 472 of file class.ActiveRecord.php.

References arException\RECORD_NOT_FOUND.

Referenced by ilSecurePathDefinitionProcessor\beginTag(), ilBiblLibraryFactory\findById(), ilBiblTranslationFactory\findById(), ilADNNotificationGUI\getNotificationsFromRequest(), and ilBiblFieldFactory\getType().

472  : \ActiveRecord
473  {
474  $obj = self::find($primary_key, $add_constructor_args);
475  if (is_null($obj)) {
477  }
478 
479  return $obj;
480  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the caller graph for this function:

◆ findOrGetInstance()

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

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

References null.

487  : \ActiveRecord
488  {
489  $obj = self::find($primary_key, $add_constructor_args);
490  if ($obj !== null) {
491  return $obj;
492  }
493 
494  $class_name = static::class;
495  $obj = arFactory::getInstance($class_name, 0, $add_constructor_args);
496  $obj->setPrimaryFieldValue($primary_key);
497  $obj->is_new = true;
498  $obj->storeObjectToCache();
499 
500  return $obj;
501  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null

◆ first()

static ActiveRecord::first ( )
static

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

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

636  : ?\ActiveRecord
637  {
638  $activeRecordList = new ActiveRecordList(self::getCalledClass());
639 
640  return $activeRecordList->first();
641  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the caller graph for this function:

◆ fixDateField()

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

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

References getArConnector(), and getArFieldList().

168  {
169  if ($this->getArFieldList()->getFieldByName($field_name)->isDateField()) {
170  return $this->getArConnector()->fixDate($value);
171  }
172 
173  return $value;
174  }
+ Here is the call graph for this function:

◆ flushDB()

static ActiveRecord::flushDB ( )
staticfinal

never use in ILIAS Core, Plugins only

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

Referenced by ilMMTopItemGUI\restore().

326  : void
327  {
328  self::truncateDB();
329  }
+ Here is the caller graph for this function:

◆ fromCamelCase()

static ActiveRecord::fromCamelCase ( string  $str)
staticprotected

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

References $c.

728  : ?string
729  {
730  $str[0] = strtolower($str[0]);
731 
732  return preg_replace_callback('/([A-Z])/', fn($c): string => "_" . strtolower($c[1]), $str);
733  }
$c
Definition: deliver.php:25

◆ get()

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

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

Referenced by ilBiblLibraryFactory\getAll(), ILIAS\GlobalScreen\ADNProvider\getNotifications(), and ilADNNotificationGUI\getNotificationsFromRequest().

622  : array
623  {
624  $activeRecordList = new ActiveRecordList(self::getCalledClass());
625 
626  return $activeRecordList->get();
627  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the caller graph for this function:

◆ getArConnector()

ActiveRecord::getArConnector ( )

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

References arConnectorMap\get().

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

33  : \arConnector
34  {
35  return arConnectorMap::get($this);
36  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static get(ActiveRecord $activeRecord)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getArFieldList()

ActiveRecord::getArFieldList ( )

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

References arFieldCache\get().

Referenced by asArray(), arWhere\asSQLStatement(), asStdClass(), buildFromArray(), CachedActiveRecord\buildHash(), copy(), create(), fixDateField(), getArrayForConnector(), CachedActiveRecord\getCacheIdentifier(), arConnectorDB\installDatabase(), installDatabase(), arConnectorDB\updateDatabase(), and arConnectorDB\updateIndices().

38  : \arFieldList
39  {
40  return arFieldCache::get($this);
41  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static get(ActiveRecord $activeRecord)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getArray()

static ActiveRecord::getArray ( ?string  $key = null,
string|array|null  $values = null 
)
static
Parameters
null$values
Returns
mixed[]|mixed[][]|int[]|string[]|null[]

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

Referenced by ilMMAbstractBaseTypeHandlerAction\__construct(), ilMMItemInformation\__construct(), ILIAS\AdministrativeNotification\DataRetrieval\getRecords(), ilOrgUnitPathStorage\getTextRepresentationOfOrgUnits(), and ILIAS\AdministrativeNotification\DataRetrieval\getTotalRowCount().

684  : array
685  {
686  $activeRecordList = new ActiveRecordList(self::getCalledClass());
687 
688  return $activeRecordList->getArray($key, $values);
689  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the caller graph for this function:

◆ getArrayForConnector()

ActiveRecord::getArrayForConnector ( )
final
Returns
array<string, mixed[]>

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

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

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

198  : array
199  {
200  $data = [];
201  foreach ($this->getArFieldList()->getFields() as $arField) {
202  $field_name = $arField->getName();
203  $sleeped = $this->sleep($field_name);
204  $var = $sleeped ?? ($this->{$field_name});
205  $data[$field_name] = [$arField->getFieldType(), $var];
206  }
207 
208  return $data;
209  }
sleep($field_name)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCalledClass()

static ActiveRecord::getCalledClass ( )
staticprotected

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

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

References arCalledClassCache\get().

221  : \ActiveRecord
222  {
223  $class = static::class;
224 
225  return arCalledClassCache::get($class);
226  }
static get(string $class_name)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ getCollection()

static ActiveRecord::getCollection ( )
static

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

Referenced by ilDclTableViewBaseDefaultValue\findAll(), and ilBiblFieldFactory\getCollectionForFilter().

644  {
645  return new ActiveRecordList(self::getCalledClass());
646  ;
647  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the caller graph for this function:

◆ getConnectorContainerName()

ActiveRecord::getConnectorContainerName ( )

Return the Name of your Connector Table

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

References $connector_container_name.

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

59  : string
60  {
61  // WILL BE ABSTRACT TO REPLACE returnDbTableName() IN NEXT VERSION
62  if ($this->connector_container_name !== '' && $this->connector_container_name !== '0') {
64  }
65 
66  $ar = self::getCalledClass();
67 
68  return $ar::returnDbTableName();
69  }
string $connector_container_name
+ Here is the caller graph for this function:

◆ getFirstFromLastQuery()

static ActiveRecord::getFirstFromLastQuery ( )
static
Deprecated:

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

659  : ?\ActiveRecord
660  {
661  $activeRecordList = new ActiveRecordList(self::getCalledClass());
662 
663  return $activeRecordList->getFirstFromLastQuery();
664  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ getPrimaryFieldValue()

ActiveRecord::getPrimaryFieldValue ( )
Returns
mixed

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

References arFieldCache\getPrimaryFieldName().

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

80  {
81  $primary_fieldname = arFieldCache::getPrimaryFieldName($this);
82 
83  return $this->{$primary_fieldname};
84  }
static getPrimaryFieldName(ActiveRecord $activeRecord)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ innerjoin()

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

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

552  $activeRecordList = new ActiveRecordList(self::getCalledClass());
553 
554  return $activeRecordList->innerjoin($tablename, $on_this, $on_external, $fields, $operator, $both_external);
555  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ innerjoinAR()

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

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

References getConnectorContainerName().

528  return self::innerjoin(
529  $activeRecord->getConnectorContainerName(),
530  $on_this,
531  $on_external,
532  $fields,
533  $operator,
534  $both_external
535  );
536  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getConnectorContainerName()
Return the Name of your Connector Table
+ Here is the call graph for this function:

◆ installConnector()

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

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

References installDatabase().

241  : bool
242  {
243  return $this->installDatabase();
244  }
+ Here is the call graph for this function:

◆ installDatabase()

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

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

References getArConnector(), and getArFieldList().

Referenced by installConnector().

279  : bool
280  {
281  if (!self::tableExists()) {
282  $fields = [];
283  foreach ($this->getArFieldList()->getFields() as $arField) {
284  $fields[$arField->getName()] = $arField->getAttributesForConnector();
285  }
286 
287  return $this->getArConnector()->installDatabase($this, $fields);
288  }
289 
290  return $this->getArConnector()->updateDatabase($this);
291  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ 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 233 of file class.ActiveRecord.php.

Referenced by arConnectorDB\resetDatabase().

233  : bool
234  {
235  return self::getCalledClass()->installDatabase();
236  }
+ Here is the caller graph for this function:

◆ last()

static ActiveRecord::last ( )
static

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

649  : ?\ActiveRecord
650  {
651  $activeRecordList = new ActiveRecordList(self::getCalledClass());
652 
653  return $activeRecordList->last();
654  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ leftjoin()

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

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

571  $activeRecordList = new ActiveRecordList(self::getCalledClass());
572 
573  return $activeRecordList->leftjoin($tablename, $on_this, $on_external, $fields, $operator, $both_external);
574  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ limit()

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

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

600  {
601  $activeRecordList = new ActiveRecordList(self::getCalledClass());
602  $activeRecordList->limit($start, $end);
603 
604  return $activeRecordList;
605  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ orderBy()

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

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

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

580  {
581  $activeRecordList = new ActiveRecordList(self::getCalledClass());
582  $activeRecordList->orderBy($orderBy, $orderDirection);
583 
584  return $activeRecordList;
585  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the caller graph for this function:

◆ preloadObjects()

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

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

References ILIAS\GlobalScreen\get().

422  : array
423  {
424  return self::get();
425  }
get(string $class_name)
+ Here is the call graph for this function:

◆ raw()

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

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

674  {
675  $activeRecordList = new ActiveRecordList(self::getCalledClass());
676 
677  return $activeRecordList->raw($set_raw);
678  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ read()

ActiveRecord::read ( )
Exceptions
arException

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

References getArConnector(), getArrayForConnector(), getPrimaryFieldValue(), null, arException\RECORD_NOT_FOUND, arObjectCache\store(), and wakeUp().

Referenced by __construct().

383  : void
384  {
385  $records = $this->getArConnector()->read($this);
386  if ($this->ar_safe_read && is_array($records) && $records === []) {
388  }
389  if (!$this->ar_safe_read && is_array($records) && $records === []) {
390  $this->is_new = true;
391  }
392  $records = is_array($records) ? $records : [];
393  foreach ($records as $record) {
394  foreach (array_keys($this->getArrayForConnector()) as $k) {
395  $waked = $this->wakeUp($k, $record->{$k} ?? null);
396  $this->{$k} = $waked ?? $record->{$k} ?? null;
397  }
398  arObjectCache::store($this);
399  }
400  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
wakeUp($field_name, $field_value)
static store(ActiveRecord $activeRecord)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:
+ 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 271 of file class.ActiveRecord.php.

271  : bool
272  {
273  return self::getCalledClass()->getArConnector()->removeField(self::getCalledClass(), $field_name);
274  }

◆ renameDBField()

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

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

250  : bool
251  {
252  return self::getCalledClass()->getArConnector()->renameField(self::getCalledClass(), $old_name, $new_name);
253  }

◆ resetDB()

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

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

310  : bool
311  {
312  return self::getCalledClass()->getArConnector()->resetDatabase(self::getCalledClass());
313  }

◆ returnDbTableName()

static ActiveRecord::returnDbTableName ( )
static
Returns
never
Exceptions

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

References arException\UNKNONWN_EXCEPTION.

48  : string
49  {
50  throw new arException(
52  'Implement getConnectorContainerName in your child-class'
53  );
54  }
const UNKNONWN_EXCEPTION
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ save()

ActiveRecord::save ( )

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

References store().

Referenced by ilExAssTypeWikiTeam\cloneSpecificProperties(), and ILIAS\BackgroundTasks\Implementation\Persistence\BasicPersistence\saveTask().

346  : void
347  {
348  $this->store();
349  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setConnectorContainerName()

ActiveRecord::setConnectorContainerName ( string  $connector_container_name)

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

References $connector_container_name.

71  : void
72  {
73  $this->connector_container_name = $connector_container_name;
74  }
string $connector_container_name

◆ setPrimaryFieldValue()

ActiveRecord::setPrimaryFieldValue (   $value)
Parameters
$value

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

References arFieldCache\getPrimaryFieldName().

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

◆ sleep()

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

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

References null.

Referenced by getArrayForConnector(), and ilADNNotification\wakeUp().

181  {
182  return null;
183  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the caller graph for this function:

◆ store()

ActiveRecord::store ( )

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

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

Referenced by save().

334  : void
335  {
336  $primary_fieldname = arFieldCache::getPrimaryFieldName($this);
337  $primary_value = $this->getPrimaryFieldValue();
338 
339  if (!self::where([$primary_fieldname => $primary_value])->hasSets()) {
340  $this->create();
341  } else {
342  $this->update();
343  }
344  }
static getPrimaryFieldName(ActiveRecord $activeRecord)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ storeObjectToCache()

ActiveRecord::storeObjectToCache ( )

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

References arObjectCache\store().

114  : void
115  {
116  arObjectCache::store($this);
117  }
static store(ActiveRecord $activeRecord)
+ Here is the call graph for this function:

◆ tableExists()

static ActiveRecord::tableExists ( )
staticfinal

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

255  : bool
256  {
257  return self::getCalledClass()->getArConnector()->checkTableExists(self::getCalledClass());
258  }

◆ truncateDB()

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

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

318  : void
319  {
320  self::getCalledClass()->getArConnector()->truncateDatabase(self::getCalledClass());
321  }

◆ update()

ActiveRecord::update ( )

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

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

Referenced by ilAccessibilityDocument\buildFromArray(), ilOrgUnitPathStorage\store(), and store().

402  : void
403  {
404  $this->getArConnector()->update($this);
405  arObjectCache::store($this);
406  }
static store(ActiveRecord $activeRecord)
+ 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 296 of file class.ActiveRecord.php.

296  : bool
297  {
298  if (!self::tableExists()) {
299  self::getCalledClass()->installDatabase();
300 
301  return true;
302  }
303 
304  return self::getCalledClass()->getArConnector()->updateDatabase(self::getCalledClass());
305  }

◆ wakeUp()

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

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

References null.

Referenced by buildFromArray(), and read().

191  {
192  return null;
193  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the caller graph for this function:

◆ where()

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

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

Referenced by ILIAS\MainMenu\Provider\CustomMainBarProvider\__construct(), ilDclTableView\createFieldSetting(), ilMMAbstractItemFacade\deleteAssociatedTranslations(), ilBiblEntryFactory\deleteEntryById(), ilAccessibilityDocument\detachCriterion(), ilObjBibliographic\doCreate(), ilBiblFieldFilterFactory\filterItemsForTable(), ilBiblFieldFilterFactory\findByFieldId(), ilBiblFieldFilterFactory\findById(), ilBiblEntryFactory\findByIdAndTypeString(), ilBiblFieldFactory\findOrCreateFieldOfAttribute(), ilBiblEntryFactory\getAllAttributesByEntryId(), ilBiblFieldFilterFactory\getAllForObjectId(), ilBiblEntryFactory\getARInstance(), ilBiblFieldFactory\getARInstance(), ilBiblAttributeFactory\getAttributesForEntry(), ILIAS\BackgroundTasks\Implementation\Persistence\BasicPersistence\getBucketIdsByState(), ILIAS\BackgroundTasks\Implementation\Persistence\BasicPersistence\getBucketIdsOfUser(), ILIAS\BackgroundTasks\Implementation\Persistence\BasicPersistence\getBucketMetaOfUser(), ilBiblFieldFilterFactory\getByObjectIdAndField(), ilBiblTranslationFactory\getCollectionOfTranslationsForField(), ilAccessibilityDocumentGUI\getDocumentsByServerRequest(), ilDclCache\getFieldProperties(), ilDclTableView\getFieldSetting(), ilDclTableView\getFieldSettings(), ilDclTableView\getFilterableFieldSettings(), ilBiblDataFactory\getIlBiblDataById(), ilBiblEntryTableGUI\getRecordsOfCurrentPage(), ilMMItemRepository\getTopItems(), ILIAS\BackgroundTasks\Implementation\Persistence\BasicPersistence\getValueContainerId(), ilDclBaseFieldModel\getViewSettings(), ilDclTableView\getVisibleFields(), ilBiblEntryFactory\loadParsedAttributesByEntryId(), ilMMItemTranslationTableGUI\parseData(), ilDclCache\preloadFieldProperties(), ilADNNotification\resetForAllUsers(), ILIAS\BackgroundTasks\Implementation\Persistence\BasicPersistence\saveTask(), and ilOrgUnitPathStorage\store().

508  {
509  $activeRecordList = new ActiveRecordList(self::getCalledClass());
510  $activeRecordList->where($where, $operator);
511 
512  return $activeRecordList;
513  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the caller graph for this function:

Field Documentation

◆ $ar_safe_read

bool ActiveRecord::$ar_safe_read = true
protected

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

◆ $connector_container_name

string ActiveRecord::$connector_container_name = ''
protected

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

Referenced by getConnectorContainerName(), and setConnectorContainerName().

◆ $is_new

bool ActiveRecord::$is_new = true
protected

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


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