ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
ActiveRecord Class Reference

Class ActiveRecord. 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 ($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 ()
 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 ()
 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

Constructor & Destructor Documentation

◆ __construct()

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

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

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

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  }
string $key
Consumer key/client ID value.
Definition: System.php:193
static get(ActiveRecord $ar)
+ 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 672 of file class.ActiveRecord.php.

References $name, and count().

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  }
if($format !==null) $name
Definition: metadata.php:247
+ Here is the call graph for this function:

◆ _toCamelCase()

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

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

References $c.

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

◆ additionalParams()

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

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

References Vendor\Package\$e, arObjectCache\get(), and arObjectCache\isCached().

404  {
405  $srModelObjectList = new ActiveRecordList(self::getCalledClass());
406  $srModelObjectList->additionalParams($additional_params);
407 
408  return $srModelObjectList;
409  }
NullPointerExceptionInspection
+ Here is the call graph for this function:

◆ 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  }
NullPointerExceptionInspection

◆ afterObjectLoad()

ActiveRecord::afterObjectLoad ( )

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.

References getArFieldList().

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

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  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildFromArray()

ActiveRecord::buildFromArray ( array  $array)

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

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

122  : \ActiveRecord
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  }
134  arObjectCache::store($this);
135 
136  return $this;
137  }
Class ActiveRecord.
static store(ActiveRecord $object)
static get($class, $id)
wakeUp($field_name, $field_value)
static isCached($class, $id)
+ Here is the call graph for this function:

◆ connector()

static ActiveRecord::connector ( arConnector  $connector)
static

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

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

◆ copy()

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

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

References arException\COPY_DESTINATION_ID_EXISTS, and getArFieldList().

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  }
const COPY_DESTINATION_ID_EXISTS
Class arException.
+ Here is the call graph for this function:

◆ count()

◆ create()

ActiveRecord::create ( )

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

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

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

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);
333  arObjectCache::store($this);
334  }
static getPrimaryFieldName(ActiveRecord $ar)
static store(ActiveRecord $object)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dateFormat()

static ActiveRecord::dateFormat ( 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  }
NullPointerExceptionInspection

◆ delete()

ActiveRecord::delete ( )

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

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

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

382  {
383  $this->getArConnector()->delete($this);
384  arObjectCache::purge($this);
385  }
static purge(ActiveRecord $object)
+ 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 238 of file class.ActiveRecord.php.

238  : bool
239  {
240  return self::getCalledClass()->getArConnector()->checkFieldExists(self::getCalledClass(), $field_name);
241  }

◆ 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.

References arException\RECORD_NOT_FOUND.

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

445  : \ActiveRecord
446  {
447  $obj = self::find($primary_key, $add_constructor_args);
448  if (is_null($obj)) {
450  }
451 
452  return $obj;
453  }
Class ActiveRecord.
Class arException.
+ Here is the caller graph for this function:

◆ findOrGetInstance()

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

Referenced by ilOrgUnitPositionFormGUI\fillForm(), ilOrgUnitPositionGUI\getPositionFromRequest(), and ILIAS\Modules\EmployeeTalk\TalkSeries\Repository\IliasDBEmployeeTalkSeriesRepository\storeEmployeeTalkSerieSettings().

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  }
+ Here is the caller graph for this function:

◆ first()

static ActiveRecord::first ( )
static

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

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

609  : ?\ActiveRecord
610  {
611  $srModelObjectList = new ActiveRecordList(self::getCalledClass());
612 
613  return $srModelObjectList->first();
614  }
Class ActiveRecord.
NullPointerExceptionInspection
+ 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 145 of file class.ActiveRecord.php.

References getArConnector(), and getArFieldList().

146  {
147  if ($this->getArFieldList()->getFieldByName($field_name)->isDateField()) {
148  return $this->getArConnector()->fixDate($value);
149  }
150 
151  return $value;
152  }
+ Here is the call graph for this function:

◆ flushDB()

static ActiveRecord::flushDB ( )
staticfinal

never use in ILIAS Core, Plugins only

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

Referenced by ilMMTopItemGUI\restore().

300  : void
301  {
302  self::truncateDB();
303  }
+ Here is the caller graph for this function:

◆ fromCamelCase()

static ActiveRecord::fromCamelCase ( string  $str)
staticprotected

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

References $c.

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

◆ get()

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

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

Referenced by ilGlobalCacheMetricsCollectedObjective\collectFrom(), ilBiblLibraryFactory\getAll(), and ILIAS\AdministrativeNotification\GlobalScreen\ADNProvider\getNotifications().

595  : array
596  {
597  $srModelObjectList = new ActiveRecordList(self::getCalledClass());
598 
599  return $srModelObjectList->get();
600  }
NullPointerExceptionInspection
+ Here is the caller graph for this function:

◆ getArConnector()

ActiveRecord::getArConnector ( )

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

References arConnectorMap\get().

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

30  : \arConnector
31  {
32  return arConnectorMap::get($this);
33  }
Class arConnector.
static get(ActiveRecord $ar)
+ 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.

References arFieldCache\get().

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

35  : \arFieldList
36  {
37  return arFieldCache::get($this);
38  }
Class arFieldList.
static get(ActiveRecord $ar)
+ 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.

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

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

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)
+ 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 196 of file class.ActiveRecord.php.

References arCalledClassCache\get().

196  : \ActiveRecord
197  {
198  $class = static::class;
199 
200  return arCalledClassCache::get($class);
201  }
static get(string $class_name)
Class ActiveRecord.
+ Here is the call graph for this function:

◆ getCollection()

static ActiveRecord::getCollection ( )
static

◆ getConnectorContainerName()

ActiveRecord::getConnectorContainerName ( )

◆ getFirstFromLastQuery()

static ActiveRecord::getFirstFromLastQuery ( )
static
Deprecated:

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

632  : ?\ActiveRecord
633  {
634  $srModelObjectList = new ActiveRecordList(self::getCalledClass());
635 
636  return $srModelObjectList->getFirstFromLastQuery();
637  }
Class ActiveRecord.
NullPointerExceptionInspection

◆ getPrimaryFieldValue()

ActiveRecord::getPrimaryFieldValue ( )
Returns
mixed

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

References arFieldCache\getPrimaryFieldName().

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

76  {
77  $primary_fieldname = arFieldCache::getPrimaryFieldName($this);
78 
79  return $this->{$primary_fieldname};
80  }
static getPrimaryFieldName(ActiveRecord $ar)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ innerjoin()

static ActiveRecord::innerjoin (   $tablename,
  $on_this,
  $on_external,
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.

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

525  $srModelObjectList = new ActiveRecordList(self::getCalledClass());
526 
527  return $srModelObjectList->innerjoin($tablename, $on_this, $on_external, $fields, $operator, $both_external);
528  }
NullPointerExceptionInspection
+ 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.

References getConnectorContainerName().

501  return self::innerjoin(
503  $on_this,
504  $on_external,
505  $fields,
506  $operator,
507  $both_external
508  );
509  }
NullPointerExceptionInspection
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 216 of file class.ActiveRecord.php.

References installDatabase().

216  : bool
217  {
218  return $this->installDatabase();
219  }
+ Here is the call graph for this function:

◆ installDatabase()

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

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

References getArConnector(), and getArFieldList().

Referenced by installConnector().

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  }
+ 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 208 of file class.ActiveRecord.php.

Referenced by arConnectorDB\resetDatabase().

208  : bool
209  {
210  return self::getCalledClass()->installDatabase();
211  }
+ Here is the caller graph for this function:

◆ last()

static ActiveRecord::last ( )
static

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

622  : ?\ActiveRecord
623  {
624  $srModelObjectList = new ActiveRecordList(self::getCalledClass());
625 
626  return $srModelObjectList->last();
627  }
Class ActiveRecord.
NullPointerExceptionInspection

◆ 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  }
NullPointerExceptionInspection

◆ 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  }
NullPointerExceptionInspection

◆ orderBy()

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

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

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

553  {
554  $srModelObjectList = new ActiveRecordList(self::getCalledClass());
555  $srModelObjectList->orderBy($orderBy, $orderDirection);
556 
557  return $srModelObjectList;
558  }
NullPointerExceptionInspection
+ Here is the caller graph for this function:

◆ preloadObjects()

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

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

References ILIAS\Repository\get().

395  : array
396  {
397  return self::get();
398  }
get(string $key, Refinery\Transformation $t)
Get passed parameter, if not data passed, get key from http request.
+ 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  }
NullPointerExceptionInspection

◆ read()

ActiveRecord::read ( )
Exceptions
arException

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

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

Referenced by __construct().

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  }
371  arObjectCache::store($this);
372  }
373  }
static store(ActiveRecord $object)
wakeUp($field_name, $field_value)
Class arException.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeDBField()

static ActiveRecord::removeDBField ( 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()

static ActiveRecord::returnDbTableName ( )
static
Exceptions

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

References arException\UNKNONWN_EXCEPTION.

44  : string
45  {
46  throw new arException(
48  'Implement getConnectorContainerName in your child-class'
49  );
50  }
const UNKNONWN_EXCEPTION
Class arException.

◆ save()

ActiveRecord::save ( )

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

References store().

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

320  : void
321  {
322  $this->store();
323  }
+ 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 67 of file class.ActiveRecord.php.

References $connector_container_name.

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

◆ setPrimaryFieldValue()

ActiveRecord::setPrimaryFieldValue (   $value)
Parameters
$value

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

References arFieldCache\getPrimaryFieldName().

85  : void
86  {
87  $primary_fieldname = arFieldCache::getPrimaryFieldName($this);
88 
89  $this->{$primary_fieldname} = $value;
90  }
static getPrimaryFieldName(ActiveRecord $ar)
+ Here is the call graph for this function:

◆ sleep()

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

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

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

159  {
160  return null;
161  }
+ Here is the caller graph for this function:

◆ store()

ActiveRecord::store ( )

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

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

Referenced by save(), and ilTermsOfServiceDocumentTest\testCriteriaCanBeAttachedToAndDetachedFromDocumentPersistently().

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  }
static getPrimaryFieldName(ActiveRecord $ar)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ storeObjectToCache()

ActiveRecord::storeObjectToCache ( )

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

References arObjectCache\store().

106  : void
107  {
108  arObjectCache::store($this);
109  }
static store(ActiveRecord $object)
+ 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 ( )

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

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

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

376  {
377  $this->getArConnector()->update($this);
378  arObjectCache::store($this);
379  }
static store(ActiveRecord $object)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateDB()

static ActiveRecord::updateDB ( )
staticfinal
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

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

Referenced by buildFromArray(), and read().

169  {
170  return null;
171  }
+ Here is the caller graph for this function:

◆ where()

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

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

Referenced by ILIAS\MainMenu\Provider\CustomMainBarProvider\__construct(), ilOrgUnitPosition\afterObjectLoad(), ilDclTableView\createFieldSetting(), ilObjOrgUnit\delete(), ilMMAbstractItemFacade\deleteAssociatedTranslations(), ilBiblEntryFactory\deleteEntryById(), ilTermsOfServiceDocument\detachCriterion(), ilAccessibilityDocument\detachCriterion(), ilObjBibliographic\doCreate(), ilBiblFieldFilterFactory\filterItemsForTable(), OrgUnit\Positions\UserAssignment\ilOrgUnitUserAssignmentRepository\findAllUserAssingmentsByUserIds(), ilBiblFieldFilterFactory\findByFieldId(), ilBiblEntryFactory\findByIdAndTypeString(), ilOrgUnitOperationContextQueries\findByName(), ilOrgUnitOperationQueries\findByOperationString(), OrgUnit\Positions\UserAssignment\ilOrgUnitUserAssignmentRepository\findOrCreateAssignment(), ilBiblFieldFactory\findOrCreateFieldOfAttribute(), ilBiblEntryFactory\getAllAttributesByEntryId(), ilBiblFieldFilterFactory\getAllForObjectId(), 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\getDependentAuthorities(), ilAccessibilityDocumentGUI\getDocumentsByServerRequest(), ilTermsOfServiceDocumentGUI\getDocumentsByServerRequest(), ilDclCache\getFieldProperties(), ilDclTableView\getFieldSetting(), ilDclTableView\getFieldSettings(), ilDclTableView\getFilterableFieldSettings(), ilBiblDataFactory\getIlBiblDataById(), ilOrgUnitOperationQueries\getOperationsForContextId(), ilOrgUnitOperationQueries\getOperationsForContextName(), ilOrgUnitUserAssignmentQueries\getOrgUnitIdsOfUsersPosition(), OrgUnit\Positions\UserAssignment\ilOrgUnitUserAssignmentRepository\getOrgUnitIdsOfUsersPosition(), ilDclTableHelper\getStandardViewsByVisibleTables(), OrgUnit\User\ilOrgUnitUserRepository\getSuperiorsSql(), ilOrgUnitPermissionQueries\getTemplateSetForContextName(), ilMMItemRepository\getTopItems(), ilTermsOfServiceSettingsFormGUI\getTranslatedError(), 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(), ilOrgUnitUserAssignmentQueries\getUserIdsOfUsersOrgUnitsInPosition(), OrgUnit\Positions\UserAssignment\ilOrgUnitUserAssignmentRepository\getUserIdsOfUsersOrgUnitsInPosition(), ILIAS\BackgroundTasks\Implementation\Persistence\BasicPersistence\getValueContainerId(), ilDclBaseFieldModel\getViewSettings(), ilDclTableView\getVisibleFields(), ilOrgUnitPermissionQueries\hasLocalSet(), ilBiblEntryFactory\loadParsedAttributesByEntryId(), ilMMItemTranslationTableGUI\parseData(), ilDclCache\preloadFieldProperties(), ilOrgUnitOperationContextQueries\registerNewContext(), ilADNNotification\resetForAllUsers(), ILIAS\OrgUnit\Webservices\SOAP\RemoveUserIdFromPositionInOrgUnit\run(), ILIAS\BackgroundTasks\Implementation\Persistence\BasicPersistence\saveTask(), ilObjTermsOfServiceGUI\showMissingDocuments(), ilOrgUnitSimpleUserImport\simpleUserImportElement(), ilOrgUnitPathStorage\store(), and ilOrgUnitPosition\storeAuthorities().

481  {
482  $srModelObjectList = new ActiveRecordList(self::getCalledClass());
483  $srModelObjectList->where($where, $operator);
484 
485  return $srModelObjectList;
486  }
NullPointerExceptionInspection
+ 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: