ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
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, $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, $on_external, array $fields=[' *'], string $operator='=', bool $both_external=false)
 
static innerjoin ( $tablename, $on_this, $on_external, array $fields=[' *'], string $operator='=', bool $both_external=false)
 
static leftjoin ( $tablename, $on_this, $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, $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 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
Version
2.0.7

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

Constructor & Destructor Documentation

◆ __construct()

ActiveRecord::__construct ( mixed  $primary_key = 0)

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

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

98  {
99  $arFieldList = arFieldCache::get($this);
100 
101  $primaryFieldName = $arFieldList->getPrimaryFieldName();
102  $this->{$primaryFieldName} = $primary_key;
103  if ($primary_key === 0) {
104  return;
105  }
106  if ($primary_key === null) {
107  return;
108  }
109  if ($primary_key === false) {
110  return;
111  }
112  $this->read();
113  }
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 701 of file class.ActiveRecord.php.

References count().

702  {
703  // Getter
704  if (preg_match("/get([a-zA-Z]*)/u", $name, $matches) && (is_countable($arguments) ? count(
705  $arguments
706  ) : 0) === 0) {
707  return $this->{self::fromCamelCase($matches[1])};
708  }
709  // Setter
710  if (!preg_match("/set([a-zA-Z]*)/u", $name, $matches)) {
711  return;
712  }
713  if (count($arguments) !== 1) {
714  return;
715  }
716  $this->{self::fromCamelCase($matches[1])} = $arguments[0];
717  }
+ 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:9

◆ additionalParams()

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

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

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

432  {
433  $activeRecordList = new ActiveRecordList(self::getCalledClass());
434  $activeRecordList->additionalParams($additional_params);
435 
436  return $activeRecordList;
437  }
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 608 of file class.ActiveRecord.php.

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

◆ afterObjectLoad()

ActiveRecord::afterObjectLoad ( )

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

377  : void
378  {
379  }

◆ asArray()

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

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

References getArFieldList().

Referenced by arConnectorCache\storeActiveRecordInCache().

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

◆ asStdClass()

ActiveRecord::asStdClass ( )

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

References getArFieldList().

Referenced by arConnectorSession\create().

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

◆ buildFromArray()

ActiveRecord::buildFromArray ( array  $array)

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

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

145  : static
146  {
147  $class = $this::class;
148  $primary = $this->getArFieldList()->getPrimaryFieldName();
149  $primary_value = $array[$primary];
150  if ($primary_value && arObjectCache::isCached($class, $primary_value)) {
151  return arObjectCache::get($class, $primary_value);
152  }
153  foreach ($array as $field_name => $value) {
154  $waked = $this->wakeUp($field_name, $value);
155  $this->{$field_name} = $waked ?? $value;
156  }
157  arObjectCache::store($this);
158 
159  return $this;
160  }
static get($class, $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 667 of file class.ActiveRecord.php.

668  {
669  $activeRecordList = new ActiveRecordList(self::getCalledClass());
670 
671  return $activeRecordList->connector($arConnector);
672  }
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 366 of file class.ActiveRecord.php.

References arException\COPY_DESTINATION_ID_EXISTS, and getArFieldList().

366  : self
367  {
368  if (self::where([$this->getArFieldList()->getPrimaryFieldName() => $new_id])->hasSets()) {
370  }
371  $new_obj = clone($this);
372  $new_obj->setPrimaryFieldValue($new_id);
373 
374  return $new_obj;
375  }
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 615 of file class.ActiveRecord.php.

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

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

◆ create()

ActiveRecord::create ( )

Definition at line 352 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().

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

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

◆ debug()

static ActiveRecord::debug ( )
static

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

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

◆ delete()

ActiveRecord::delete ( )

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

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

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

409  : void
410  {
411  $this->getArConnector()->delete($this);
412  arObjectCache::purge($this);
413  }
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 264 of file class.ActiveRecord.php.

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

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

References arException\RECORD_NOT_FOUND.

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

473  : \ActiveRecord
474  {
475  $obj = self::find($primary_key, $add_constructor_args);
476  if (is_null($obj)) {
478  }
479 
480  return $obj;
481  }
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 488 of file class.ActiveRecord.php.

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

◆ first()

static ActiveRecord::first ( )
static

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

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

637  : ?\ActiveRecord
638  {
639  $activeRecordList = new ActiveRecordList(self::getCalledClass());
640 
641  return $activeRecordList->first();
642  }
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,
  $value 
)
Parameters
$field_name
$value
Returns
string|mixed NullPointerExceptionInspection

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

References getArConnector(), and getArFieldList().

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

◆ flushDB()

static ActiveRecord::flushDB ( )
staticfinal

never use in ILIAS Core, Plugins only

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

Referenced by ilMMTopItemGUI\restore().

327  : void
328  {
329  self::truncateDB();
330  }
+ 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:9

◆ get()

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

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

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

623  : array
624  {
625  $activeRecordList = new ActiveRecordList(self::getCalledClass());
626 
627  return $activeRecordList->get();
628  }
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 34 of file class.ActiveRecord.php.

References arConnectorMap\get().

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

34  : \arConnector
35  {
36  return arConnectorMap::get($this);
37  }
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 39 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().

39  : \arFieldList
40  {
41  return arFieldCache::get($this);
42  }
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,
  $values = null 
)
static
Parameters
null$values
Returns
mixed[]|mixed[][]|int[]|string[]|null[]

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

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

685  : array
686  {
687  $activeRecordList = new ActiveRecordList(self::getCalledClass());
688 
689  return $activeRecordList->getArray($key, $values);
690  }
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 199 of file class.ActiveRecord.php.

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

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

199  : array
200  {
201  $data = [];
202  foreach ($this->getArFieldList()->getFields() as $arField) {
203  $field_name = $arField->getName();
204  $sleeped = $this->sleep($field_name);
205  $var = $sleeped ?? ($this->{$field_name});
206  $data[$field_name] = [$arField->getFieldType(), $var];
207  }
208 
209  return $data;
210  }
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 222 of file class.ActiveRecord.php.

References arCalledClassCache\get().

222  : \ActiveRecord
223  {
224  $class = static::class;
225 
226  return arCalledClassCache::get($class);
227  }
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 644 of file class.ActiveRecord.php.

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

645  {
646  return new ActiveRecordList(self::getCalledClass());
647  ;
648  }
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 60 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().

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

◆ getFirstFromLastQuery()

static ActiveRecord::getFirstFromLastQuery ( )
static
Deprecated:

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

660  : ?\ActiveRecord
661  {
662  $activeRecordList = new ActiveRecordList(self::getCalledClass());
663 
664  return $activeRecordList->getFirstFromLastQuery();
665  }
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 80 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().

81  {
82  $primary_fieldname = arFieldCache::getPrimaryFieldName($this);
83 
84  return $this->{$primary_fieldname};
85  }
static getPrimaryFieldName(ActiveRecord $activeRecord)
+ 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 = ['*'],
string  $operator = '=',
bool  $both_external = false 
)
static
Parameters
$tablename
$on_this
$on_external
Returns
$this

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

553  $activeRecordList = new ActiveRecordList(self::getCalledClass());
554 
555  return $activeRecordList->innerjoin($tablename, $on_this, $on_external, $fields, $operator, $both_external);
556  }
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,
  $on_external,
array  $fields = ['*'],
string  $operator = '=',
bool  $both_external = false 
)
static
Parameters
$on_this
$on_external
Returns
$this

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

References getConnectorContainerName().

529  return self::innerjoin(
530  $activeRecord->getConnectorContainerName(),
531  $on_this,
532  $on_external,
533  $fields,
534  $operator,
535  $both_external
536  );
537  }
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 242 of file class.ActiveRecord.php.

References installDatabase().

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

◆ installDatabase()

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

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

References getArConnector(), and getArFieldList().

Referenced by installConnector().

280  : bool
281  {
282  if (!self::tableExists()) {
283  $fields = [];
284  foreach ($this->getArFieldList()->getFields() as $arField) {
285  $fields[$arField->getName()] = $arField->getAttributesForConnector();
286  }
287 
288  return $this->getArConnector()->installDatabase($this, $fields);
289  }
290 
291  return $this->getArConnector()->updateDatabase($this);
292  }
+ 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 234 of file class.ActiveRecord.php.

Referenced by arConnectorDB\resetDatabase().

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

◆ last()

static ActiveRecord::last ( )
static

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

650  : ?\ActiveRecord
651  {
652  $activeRecordList = new ActiveRecordList(self::getCalledClass());
653 
654  return $activeRecordList->last();
655  }
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 (   $tablename,
  $on_this,
  $on_external,
array  $fields = ['*'],
string  $operator = '=',
bool  $both_external = false 
)
static
Parameters
$tablename
$on_this
$on_external
Returns
$this

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

572  $activeRecordList = new ActiveRecordList(self::getCalledClass());
573 
574  return $activeRecordList->leftjoin($tablename, $on_this, $on_external, $fields, $operator, $both_external);
575  }
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 600 of file class.ActiveRecord.php.

601  {
602  $activeRecordList = new ActiveRecordList(self::getCalledClass());
603  $activeRecordList->limit($start, $end);
604 
605  return $activeRecordList;
606  }
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 580 of file class.ActiveRecord.php.

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

581  {
582  $activeRecordList = new ActiveRecordList(self::getCalledClass());
583  $activeRecordList->orderBy($orderBy, $orderDirection);
584 
585  return $activeRecordList;
586  }
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 423 of file class.ActiveRecord.php.

References ILIAS\GlobalScreen\get().

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

◆ raw()

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

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

675  {
676  $activeRecordList = new ActiveRecordList(self::getCalledClass());
677 
678  return $activeRecordList->raw($set_raw);
679  }
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 384 of file class.ActiveRecord.php.

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

Referenced by __construct().

384  : void
385  {
386  $records = $this->getArConnector()->read($this);
387  if ($this->ar_safe_read && is_array($records) && $records === []) {
389  }
390  if (!$this->ar_safe_read && is_array($records) && $records === []) {
391  $this->is_new = true;
392  }
393  $records = is_array($records) ? $records : [];
394  foreach ($records as $record) {
395  foreach (array_keys($this->getArrayForConnector()) as $k) {
396  $waked = $this->wakeUp($k, $record->{$k} ?? null);
397  $this->{$k} = $waked ?? $record->{$k} ?? null;
398  }
399  arObjectCache::store($this);
400  }
401  }
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 272 of file class.ActiveRecord.php.

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

◆ renameDBField()

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

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

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

◆ resetDB()

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

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

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

◆ returnDbTableName()

static ActiveRecord::returnDbTableName ( )
static
Returns
never
Exceptions

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

References arException\UNKNONWN_EXCEPTION.

49  : string
50  {
51  throw new arException(
53  'Implement getConnectorContainerName in your child-class'
54  );
55  }
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 347 of file class.ActiveRecord.php.

References store().

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

347  : void
348  {
349  $this->store();
350  }
+ 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 72 of file class.ActiveRecord.php.

References $connector_container_name.

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

◆ setPrimaryFieldValue()

ActiveRecord::setPrimaryFieldValue (   $value)
Parameters
$value

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

References arFieldCache\getPrimaryFieldName().

90  : void
91  {
92  $primary_fieldname = arFieldCache::getPrimaryFieldName($this);
93 
94  $this->{$primary_fieldname} = $value;
95  }
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 181 of file class.ActiveRecord.php.

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

182  {
183  return null;
184  }
+ Here is the caller graph for this function:

◆ store()

ActiveRecord::store ( )

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

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

Referenced by save().

335  : void
336  {
337  $primary_fieldname = arFieldCache::getPrimaryFieldName($this);
338  $primary_value = $this->getPrimaryFieldValue();
339 
340  if (!self::where([$primary_fieldname => $primary_value])->hasSets()) {
341  $this->create();
342  } else {
343  $this->update();
344  }
345  }
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 115 of file class.ActiveRecord.php.

References arObjectCache\store().

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

◆ tableExists()

static ActiveRecord::tableExists ( )
staticfinal

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

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

◆ truncateDB()

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

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

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

◆ update()

ActiveRecord::update ( )

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

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

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

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

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

◆ wakeUp()

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

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

Referenced by buildFromArray(), and read().

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

◆ where()

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

Definition at line 508 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(), ilDclTableHelper\getStandardViewsByVisibleTables(), 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().

509  {
510  $activeRecordList = new ActiveRecordList(self::getCalledClass());
511  $activeRecordList->where($where, $operator);
512 
513  return $activeRecordList;
514  }
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 30 of file class.ActiveRecord.php.

◆ $connector_container_name

string ActiveRecord::$connector_container_name = ''
protected

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

Referenced by getConnectorContainerName(), and setConnectorContainerName().

◆ $is_new

bool ActiveRecord::$is_new = true
protected

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


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