ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ActiveRecord Class Reference

Class ActiveRecord. More...

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

Public Member Functions

 getArConnector ()
 
 getArFieldList ()
 
 getConnectorContainerName ()
 
 setConnectorContainerName ($connector_container_name)
 
 getPrimaryFieldValue ()
 
 setPrimaryFieldValue ($value)
 
 __construct ($primary_key=0, arConnector $connector=null)
 
 storeObjectToCache ()
 
 __getConvertedDateFieldsAsArray ($format=null)
 
 __asCsv ($separator=';', $header=false)
 
 __asArray ()
 
 __asStdClass ()
 
 __asSerializedObject ()
 
 buildFromArray (array $array)
 
 fixDateField ($field_name, $value)
 
 sleep ($field_name)
 
 wakeUp ($field_name, $field_value)
 
 getArrayForDb ()
 
 getArrayForConnector ()
 
 installConnector ()
 
 store ()
 
 save ()
 
 create ()
 
 copy ($new_id=0)
 
 afterObjectLoad ()
 
 read ()
 
 update ()
 
 delete ()
 
 __call ($name, $arguments)
 

Static Public Member Functions

static returnDbTableName ()
 
static installDB ()
 
static renameDBField ($old_name, $new_name)
 
static tableExists ()
 
static fieldExists ($field_name)
 
static removeDBField ($field_name)
 
static updateDB ()
 
static resetDB ()
 
static truncateDB ()
 
static flushDB ()
 
static preloadObjects ()
 
static additionalParams (array $additional_params)
 
static findOrFail ($primary_key, array $add_constructor_args=array())
 Tries to find the object and throws an Exception if object is not found, instead of returning null. More...
 
static findOrGetInstance ($primary_key, array $add_constructor_args=array())
 
static where ($where, $operator=null)
 
static innerjoinAR (ActiveRecord $ar, $on_this, $on_external, $fields=array(' *'), $operator='=', $both_external=false)
 
static innerjoin ($tablename, $on_this, $on_external, $fields=array(' *'), $operator='=', $both_external=false)
 
static leftjoin ($tablename, $on_this, $on_external, $fields=array(' *'), $operator='=', $both_external=false)
 
static orderBy ($orderBy, $orderDirection='ASC')
 
static dateFormat ($date_format='d.m.Y - H:i:s')
 
static limit ($start, $end)
 
static affectedRows ()
 
static count ()
 
static get ()
 
static debug ()
 
static first ()
 
static getCollection ()
 
static last ()
 
static getFirstFromLastQuery ()
 
static connector (arConnector $connector)
 
static raw ($set_raw=true)
 
static getArray ($key=null, $values=null)
 
static _toCamelCase ($str, $capitalise_first_char=false)
 

Data Fields

const ACTIVE_RECORD_VERSION = '2.0.7'
 

Protected Member Functions

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

Static Protected Member Functions

static getCalledClass ()
 
static fromCamelCase ($str)
 

Protected Attributes

 $ar_safe_read = true
 
 $connector_container_name = ''
 

Detailed Description

Class ActiveRecord.

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

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

Constructor & Destructor Documentation

◆ __construct()

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

Reimplemented in CachedActiveRecord.

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

118 {
119 // if ($connector == null) {
120 // $connector = new arConnectorDB();
121 // }
122 // arConnectorMap::register($this, $connector);
123
124 $arFieldList = arFieldCache::get($this);
125
126 $key = $arFieldList->getPrimaryFieldName();
127 $this->{$key} = $primary_key;
128 if ($primary_key !== 0 and $primary_key !== null and $primary_key !== false) {
129 $this->read();
130 }
131 }
static get(ActiveRecord $ar)
$key
Definition: croninfo.php:18

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

+ Here is the call graph for this function:

Member Function Documentation

◆ __asArray()

ActiveRecord::__asArray ( )
Returns
array

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

212 {
213 $return = array();
214 foreach ($this->getArFieldList()->getFields() as $field) {
215 $fieldname = $field->getName();
216 $return[$fieldname] = $this->{$fieldname};
217 }
218
219 return $return;
220 }

References getArFieldList().

Referenced by __asCsv().

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

◆ __asCsv()

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

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

173 {
174 $line = '';
175 if ($header) {
176 $line .= implode($separator, array_keys($this->getArFieldList()->getRawFields()));
177 $line .= "\n";
178 }
179 $array = array();
180 foreach ($this->__asArray() as $field_name => $value) {
181 $serialized = $this->serializeToCSV($field_name);
182 if ($serialized === null) {
183 $array[$field_name] = $this->{$field_name};
184 } else {
185 $array[$field_name] = $serialized;
186 }
187 }
188 $line .= implode($separator, array_values($array));
189
190 return $line;
191 }
serializeToCSV($field)
This method is called for every field of your instance if you use __asCsv.

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

+ Here is the call graph for this function:

◆ __asSerializedObject()

ActiveRecord::__asSerializedObject ( )
Returns
string

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

242 {
243 return serialize($this);
244 }

◆ __asStdClass()

ActiveRecord::__asStdClass ( )
Returns
stdClass

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

227 {
228 $return = new stdClass();
229 foreach ($this->getArFieldList()->getFields() as $field) {
230 $fieldname = $field->getName();
231 $return->{$fieldname} = $this->{$fieldname};
232 }
233
234 return $return;
235 }

References getArFieldList().

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

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

◆ __call()

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

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

925 {
926 // Getter
927 if (preg_match("/get([a-zA-Z]*)/u", $name, $matches) and count($arguments) == 0) {
928 return $this->{self::fromCamelCase($matches[1])};
929 }
930 // Setter
931 if (preg_match("/set([a-zA-Z]*)/u", $name, $matches) and count($arguments) == 1) {
932 $this->{self::fromCamelCase($matches[1])} = $arguments[0];
933 }
934 if (preg_match("/findBy([a-zA-Z]*)/u", $name, $matches) and count($arguments) == 1) {
935 return self::where(array( self::fromCamelCase($matches[1]) => $arguments[0] ))->getFirst();
936 }
937 }
static where($where, $operator=null)
static fromCamelCase($str)

References $name.

◆ __getConvertedDateFieldsAsArray()

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

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

146 {
147 $converted_dates = array();
148 foreach ($this->getArFieldList()->getFields() as $field) {
149 if ($field->isDateField()) {
150 $name = $field->getName();
151 $value = $this->{$name};
152 $converted_dates[$name] = array(
153 'unformatted' => $value,
154 'unix' => strtotime($value),
155 );
156 if ($format) {
157 $converted_dates[$name]['formatted'] = date($format, strtotime($value));
158 }
159 }
160 }
161
162 return $converted_dates;
163 }
$format
Definition: metadata.php:141

References $format, $name, and getArFieldList().

+ Here is the call graph for this function:

◆ _toCamelCase()

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

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

947 {
948 if ($capitalise_first_char) {
949 $str[0] = strtoupper($str[0]);
950 }
951
952 return preg_replace_callback('/_([a-z])/', function ($c) {
953 return strtoupper($c[1]);
954 }, $str);
955 }

References $c.

Referenced by arViewField\__construct().

+ Here is the caller graph for this function:

◆ additionalParams()

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

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

596 {
597 $srModelObjectList = new ActiveRecordList(self::getCalledClass());
598 $srModelObjectList->additionalParams($additional_params);
599
600 return $srModelObjectList;
601 }
Class ActiveRecordList.

◆ affectedRows()

static ActiveRecord::affectedRows ( )
static
Returns
int

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

793 {
794 $srModelObjectList = new ActiveRecordList(self::getCalledClass());
795
796 return $srModelObjectList->affectedRows();
797 }

◆ afterObjectLoad()

ActiveRecord::afterObjectLoad ( )

Reimplemented in ilDclFieldProperty, ilOrgUnitPosition, ilOrgUnitPermission, and CachedActiveRecord.

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

536 {
537 }

◆ buildFromArray()

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

Reimplemented in CachedActiveRecord, and ilTermsOfServiceDocument.

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

253 {
254 $class = get_class($this);
255 $primary = $this->getArFieldList()->getPrimaryFieldName();
256 $primary_value = $array[$primary];
257 if ($primary_value and arObjectCache::isCached($class, $primary_value)) {
258 return arObjectCache::get($class, $primary_value);
259 }
260 foreach ($array as $field_name => $value) {
261 $waked = $this->wakeUp($field_name, $value);
262 $this->{$field_name} = ($waked === null) ? $value : $waked;
263 }
265 $this->afterObjectLoad();
266
267 return $this;
268 }
wakeUp($field_name, $field_value)
static isCached($class, $id)
static store(ActiveRecord $object)
static get($class, $id)

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

+ Here is the call graph for this function:

◆ connector()

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

Reimplemented in CachedActiveRecord.

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

882 {
883 $srModelObjectList = new ActiveRecordList(self::getCalledClass());
884
885 return $srModelObjectList->connector($connector);
886 }

◆ copy()

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

Reimplemented in CachedActiveRecord.

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

524 {
525 if (self::where(array( $this->getArFieldList()->getPrimaryFieldName() => $new_id ))->hasSets()) {
527 }
528 $new_obj = clone($this);
529 $new_obj->setPrimaryFieldValue($new_id);
530
531 return $new_obj;
532 }
Class arException.
const COPY_DESTINATION_ID_EXISTS

References arException\COPY_DESTINATION_ID_EXISTS.

◆ count()

static ActiveRecord::count ( )
static
Returns
int

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

804 {
805 return self::affectedRows();
806 }

Referenced by ilTermsOfServiceDocument\detachCriterion(), ilStudyProgrammeType\loadTranslation(), ilStudyProgrammeType\processAndStoreIconFile(), and ilOrgUnitPosition\storeAuthorities().

+ Here is the caller graph for this function:

◆ create()

ActiveRecord::create ( )

Reimplemented in ilDclFieldProperty, ilOrgUnitPosition, ilOrgUnitOperation, ilOrgUnitOperationContext, ilOrgUnitPermission, CachedActiveRecord, arStorage, ilGSIdentificationStorage, ilMMItemStorage, and ilTermsOfServiceDocumentCriterionAssignment.

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

506 {
507 if ($this->getArFieldList()->getPrimaryField()->getSequence()) {
508 $primary_fieldname = arFieldCache::getPrimaryFieldName($this);
509 $this->{$primary_fieldname} = $this->getArConnector()->nextID($this);
510 }
511
512 $this->getArConnector()->create($this, $this->getArrayForConnector());
514 }
static getPrimaryFieldName(ActiveRecord $ar)

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

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

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

◆ dateFormat()

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

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

765 :i:s')
766 {
767 $srModelObjectList = new ActiveRecordList(self::getCalledClass());
768 $srModelObjectList->dateFormat($date_format);
769
770 return $srModelObjectList;
771 }

◆ debug()

static ActiveRecord::debug ( )
static
Returns
ActiveRecordList

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

824 {
825 $srModelObjectList = new ActiveRecordList(self::getCalledClass());
826
827 return $srModelObjectList->debug();
828 }

◆ delete()

ActiveRecord::delete ( )

Reimplemented in ilDclTableView, ilOrgUnitPosition, ilOrgUnitPermission, and CachedActiveRecord.

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

571 {
572 $this->getArConnector()->delete($this);
574 }
static purge(ActiveRecord $object)

References arObjectCache\purge().

Referenced by arObjectCache\purge().

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

◆ fieldExists()

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

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

408 {
409 return self::getCalledClass()->getArConnector()->checkFieldExists(self::getCalledClass(), $field_name);
410 }

◆ findOrFail()

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

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

Parameters
$primary_key
array$add_constructor_args
Exceptions
arException
Returns
ActiveRecord

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

646 {
647 $obj = self::find($primary_key, $add_constructor_args);
648 if (is_null($obj)) {
650 }
651
652 return $obj;
653 }

References arException\RECORD_NOT_FOUND.

Referenced by ilBiblLibraryFactory\findById(), ilBiblFieldFilterFactory\findById(), ilBiblTranslationFactory\findById(), ilOrgUnitOperationQueries\findById(), and ilObjDefReader\handlerBeginTag().

+ Here is the caller graph for this function:

◆ findOrGetInstance()

static ActiveRecord::findOrGetInstance (   $primary_key,
array  $add_constructor_args = array() 
)
static
Parameters
$primary_key
array$add_constructor_args

@description Returns an existing Object with given primary-key or a new Instance with given primary-key set but not yet created

Returns
ActiveRecord

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

665 {
666 $obj = self::find($primary_key, $add_constructor_args);
667 if ($obj !== null) {
668 return $obj;
669 } else {
670 $class_name = get_called_class();
671 $obj = arFactory::getInstance($class_name, 0, $add_constructor_args);
672 $obj->setPrimaryFieldValue($primary_key);
673 $obj->is_new = true;
674 $obj->storeObjectToCache();
675
676 return $obj;
677 }
678 }

Referenced by ilDclTableViewGUI\executeCommand().

+ Here is the caller graph for this function:

◆ first()

static ActiveRecord::first ( )
static
Returns
ActiveRecord

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

835 {
836 $srModelObjectList = new ActiveRecordList(self::getCalledClass());
837
838 return $srModelObjectList->first();
839 }

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

+ Here is the caller graph for this function:

◆ fixDateField()

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

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

277 {
278 if ($this->getArFieldList()->getFieldByName($field_name)->isDateField()) {
279 return $this->getArConnector()->fixDate($value);
280 }
281
282 return $value;
283 }

◆ flushDB()

static ActiveRecord::flushDB ( )
staticfinal
Returns
bool

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

479 {
480 return self::truncateDB();
481 }

Referenced by ilMMTopItemGUI\restore().

+ Here is the caller graph for this function:

◆ fromCamelCase()

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

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

964 {
965 $str[0] = strtolower($str[0]);
966
967 return preg_replace_callback('/([A-Z])/', function ($c) {
968 return "_" . strtolower($c[1]);
969 }, $str);
970 }

References $c.

◆ get()

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

Reimplemented in ilOrgUnitPosition.

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

813 {
814 $srModelObjectList = new ActiveRecordList(self::getCalledClass());
815
816 return $srModelObjectList->get();
817 }

Referenced by ilBiblLibraryFactory\getAll(), ilStudyProgrammeType\getAllTypes(), and arConfigFormGUI\getValuesForItem().

+ Here is the caller graph for this function:

◆ getArConnector()

ActiveRecord::getArConnector ( )
Returns
\arConnectorDB

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

41 {
42 return arConnectorMap::get($this);
43 }
static get(ActiveRecord $ar)

References arConnectorMap\get().

Referenced by arWhere\asSQLStatement().

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

◆ getArFieldList()

ActiveRecord::getArFieldList ( )
Returns
\arFieldList

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

50 {
51 return arFieldCache::get($this);
52 }

References arFieldCache\get().

Referenced by __asArray(), __asCsv(), __asStdClass(), __getConvertedDateFieldsAsArray(), arWhere\asSQLStatement(), CachedActiveRecord\buildHash(), CachedActiveRecord\getCacheIdentifier(), arConnectorDB\installDatabase(), arConnectorDB\updateDatabase(), and arConnectorDB\updateIndices().

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

◆ getArray()

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

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

909 {
910 $srModelObjectList = new ActiveRecordList(self::getCalledClass());
911
912 return $srModelObjectList->getArray($key, $values);
913 }
$values

References $key, and $values.

Referenced by ilMMItemInformation\__construct(), ilMMAbstractBaseTypeHandlerAction\__construct(), ilOrgUnitPositionTableGUI\buildData(), ilOrgUnitPathStorage\getTextRepresentationOfOrgUnits(), ilOrgUnitUserAssignmentGUI\index(), ilOrgUnitPositionFormGUI\initFormElements(), ilMemcacheServerTableGUI\parseData(), and ilPermissionGUI\savePositionsPermissions().

+ Here is the caller graph for this function:

◆ getArrayForConnector()

ActiveRecord::getArrayForConnector ( )
final
Returns
array

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

323 {
324 $data = array();
325 foreach ($this->getArFieldList()->getFields() as $field) {
326 $field_name = $field->getName();
327 $sleeped = $this->sleep($field_name);
328 $var = ($sleeped === null) ? ($this->{$field_name}) : $sleeped;
329 $data[$field_name] = array( $field->getFieldType(), $var );
330 }
331
332 return $data;
333 }
sleep($field_name)
$data
Definition: bench.php:6

References $data.

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

+ Here is the caller graph for this function:

◆ getArrayForDb()

ActiveRecord::getArrayForDb ( )
final
Returns
array
Deprecated:

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

314 {
315 return $this->getArrayForConnector();
316 }

◆ getCalledClass()

static ActiveRecord::getCalledClass ( )
staticprotected
Returns
ActiveRecord

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

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

349 {
350 $class = get_called_class();
351
352 return arCalledClassCache::get($class);
353 }

References arCalledClassCache\get().

Referenced by getConnectorContainerName().

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

◆ getCollection()

static ActiveRecord::getCollection ( )
static
Returns
ActiveRecordList

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

846 {
847 $srModelObjectList = new ActiveRecordList(self::getCalledClass());
848
849 return $srModelObjectList;
850 }

Referenced by ilBiblFieldFactory\getCollectionForFilter(), and arStorageRecordGUI\index().

+ Here is the caller graph for this function:

◆ getConnectorContainerName()

ActiveRecord::getConnectorContainerName ( )

◆ getFirstFromLastQuery()

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

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

869 {
870 $srModelObjectList = new ActiveRecordList(self::getCalledClass());
871
872 return $srModelObjectList->getFirstFromLastQuery();
873 }

◆ getPrimaryFieldValue()

ActiveRecord::getPrimaryFieldValue ( )
Returns
mixed

Reimplemented in ilADTActiveRecordWrapper.

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

95 {
96 $primary_fieldname = arFieldCache::getPrimaryFieldName($this);
97
98 return $this->{$primary_fieldname};
99 }

References arFieldCache\getPrimaryFieldName().

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

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

◆ innerjoin()

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

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

721 {
722 $srModelObjectList = new ActiveRecordList(self::getCalledClass());
723
724 return $srModelObjectList->innerjoin($tablename, $on_this, $on_external, $fields, $operator, $both_external);
725 }

Referenced by ilMStListCoursesGUI\getActions().

+ Here is the caller graph for this function:

◆ innerjoinAR()

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

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

706 {
707 return self::innerjoin($ar->getConnectorContainerName(), $on_this, $on_external, $fields, $operator, $both_external);
708 }
static innerjoin($tablename, $on_this, $on_external, $fields=array(' *'), $operator='=', $both_external=false)

References getConnectorContainerName().

+ Here is the call graph for this function:

◆ installConnector()

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

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

376 {
377 return $this->installDatabase();
378 }

◆ installDatabase()

ActiveRecord::installDatabase ( )
finalprotected
Returns
bool

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

428 {
429 if (!$this->tableExists()) {
430 $fields = array();
431 foreach ($this->getArFieldList()->getFields() as $field) {
432 $fields[$field->getName()] = $field->getAttributesForConnector();
433 }
434
435 return $this->getArConnector()->installDatabase($this, $fields);
436 } else {
437 return $this->getArConnector()->updateDatabase($this);
438 }
439 }

◆ installDB()

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

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

365 {
366 return self::getCalledClass()->installDatabase();
367 }

Referenced by arConnectorDB\resetDatabase().

+ Here is the caller graph for this function:

◆ last()

static ActiveRecord::last ( )
static
Returns
ActiveRecord

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

857 {
858 $srModelObjectList = new ActiveRecordList(self::getCalledClass());
859
860 return $srModelObjectList->last();
861 }

◆ leftjoin()

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

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

738 {
739 $srModelObjectList = new ActiveRecordList(self::getCalledClass());
740
741 return $srModelObjectList->leftjoin($tablename, $on_this, $on_external, $fields, $operator, $both_external);
742 }

◆ limit()

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

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

781 {
782 $srModelObjectList = new ActiveRecordList(self::getCalledClass());
783 $srModelObjectList->limit($start, $end);
784
785 return $srModelObjectList;
786 }
$start
Definition: bench.php:8

References $end, and $start.

◆ orderBy()

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

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

752 {
753 $srModelObjectList = new ActiveRecordList(self::getCalledClass());
754 $srModelObjectList->orderBy($orderBy, $orderDirection);
755
756 return $srModelObjectList;
757 }

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

+ Here is the caller graph for this function:

◆ preloadObjects()

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

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

585 {
586 return self::get();
587 }

References ILIAS\GlobalScreen\get().

+ Here is the call graph for this function:

◆ raw()

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

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

895 {
896 $srModelObjectList = new ActiveRecordList(self::getCalledClass());
897
898 return $srModelObjectList->raw($set_raw);
899 }

◆ read()

ActiveRecord::read ( )
Exceptions
arException

Reimplemented in CachedActiveRecord, arStorage, and ilTermsOfServiceDocument.

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

544 {
545 $records = $this->getArConnector()->read($this);
546 if (is_array($records) && count($records) === 0 && $this->ar_safe_read === true) {
548 } elseif (is_array($records) && count($records) === 0 && $this->ar_safe_read === false) {
549 $this->is_new = true;
550 }
551 $records = is_array($records) ? $records : array();
552 foreach ($records as $rec) {
553 foreach ($this->getArrayForConnector() as $k => $v) {
554 $waked = $this->wakeUp($k, $rec->{$k});
555 $this->{$k} = ($waked === null) ? $rec->{$k} : $waked;
556 }
558 $this->afterObjectLoad();
559 }
560 }
$records
Definition: simple_test.php:22

References $records, and arException\RECORD_NOT_FOUND.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ removeDBField()

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

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

419 {
420 return self::getCalledClass()->getArConnector()->removeField(self::getCalledClass(), $field_name);
421 }

◆ renameDBField()

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

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

388 {
389 return self::getCalledClass()->getArConnector()->renameField(self::getCalledClass(), $old_name, $new_name);
390 }

◆ resetDB()

static ActiveRecord::resetDB ( )
staticfinal
Returns
bool

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

461 {
462 return self::getCalledClass()->getArConnector()->resetDatabase(self::getCalledClass());
463 }

◆ returnDbTableName()

◆ save()

ActiveRecord::save ( )

Reimplemented in CachedActiveRecord.

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

500 {
501 $this->store();
502 }

◆ serializeToCSV()

ActiveRecord::serializeToCSV (   $field)
protected

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

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

Parameters
$fieldstring
Returns
mixed

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

203 {
204 return null;
205 }

Referenced by __asCsv().

+ Here is the caller graph for this function:

◆ setConnectorContainerName()

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

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

86 {
87 $this->connector_container_name = $connector_container_name;
88 }

References $connector_container_name.

◆ setPrimaryFieldValue()

ActiveRecord::setPrimaryFieldValue (   $value)
Parameters
$value

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

106 {
107 $primary_fieldname = arFieldCache::getPrimaryFieldName($this);
108
109 $this->{$primary_fieldname} = $value;
110 }

References arFieldCache\getPrimaryFieldName().

+ Here is the call graph for this function:

◆ sleep()

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

Reimplemented in ilDclTableView, ilDclTableViewFieldSetting, ilOrgUnitPermission, and ilADTActiveRecordWrapper.

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

292 {
293 return null;
294 }

◆ store()

ActiveRecord::store ( )

Reimplemented in ilOrgUnitPathStorage, and CachedActiveRecord.

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

487 {
488 $primary_fieldname = arFieldCache::getPrimaryFieldName($this);
489 $primary_value = $this->getPrimaryFieldValue();
490
491 if (!self::where(array( $primary_fieldname => $primary_value ))->hasSets()) {
492 $this->create();
493 } else {
494 $this->update();
495 }
496 }

References arFieldCache\getPrimaryFieldName(), and League\Flysystem\Adapter\Polyfill\update().

+ Here is the call graph for this function:

◆ storeObjectToCache()

ActiveRecord::storeObjectToCache ( )

Reimplemented in CachedActiveRecord.

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

135 {
137 }

References arObjectCache\store().

+ Here is the call graph for this function:

◆ tableExists()

static ActiveRecord::tableExists ( )
staticfinal
Returns
bool

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

397 {
398 return self::getCalledClass()->getArConnector()->checkTableExists(self::getCalledClass());
399 }

◆ truncateDB()

static ActiveRecord::truncateDB ( )
staticfinal
Returns
bool

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

470 {
471 return self::getCalledClass()->getArConnector()->truncateDatabase(self::getCalledClass());
472 }

◆ update()

ActiveRecord::update ( )

Reimplemented in ilDclFieldProperty, ilOrgUnitPosition, ilOrgUnitPermission, CachedActiveRecord, arStorage, and ilTermsOfServiceDocumentCriterionAssignment.

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

564 {
565 $this->getArConnector()->update($this);
567 }

References arObjectCache\store().

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

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

◆ updateDB()

static ActiveRecord::updateDB ( )
staticfinal
Returns
bool

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

446 {
447 if (!self::tableExists()) {
448 self::getCalledClass()->installDatabase();
449
450 return true;
451 }
452
453 return self::getCalledClass()->getArConnector()->updateDatabase(self::getCalledClass());
454 }

◆ wakeUp()

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

Reimplemented in ilDclTableView, ilDclTableViewFieldSetting, ilOrgUnitPermission, and ilADTActiveRecordWrapper.

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

304 {
305 return null;
306 }

◆ where()

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

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

688 {
689 $srModelObjectList = new ActiveRecordList(self::getCalledClass());
690 $srModelObjectList->where($where, $operator);
691
692 return $srModelObjectList;
693 }

Referenced by ilStudyProgrammeUserProgress\__construct(), ilOrgUnitPosition\afterObjectLoad(), ilDclTableView\createFieldSetting(), ilObjOrgUnit\delete(), ilStudyProgrammeTypeTranslation\deleteAllTranslations(), ilMMAbstractItemFacade\deleteAssociatedTranslations(), ilBiblEntryFactory\deleteEntryById(), ilObjBibliographic\doRead(), ilBiblFieldFilterFactory\filterItemsForTable(), ilBiblFieldFilterFactory\findByFieldId(), ilBiblEntryFactory\findByIdAndTypeString(), ilOrgUnitOperationContextQueries\findByName(), ilOrgUnitOperationQueries\findByOperationString(), ilOrgUnitUserAssignment\findOrCreateAssignment(), ilBiblFieldFactory\findOrCreateFieldOfAttribute(), ilBiblEntryFactory\getAllAttributesByEntryId(), ilBiblEntryFactory\getAllEntries(), ilDclSelectionOption\getAllForField(), ilBiblFieldFilterFactory\getAllForObjectId(), ilDclTableView\getAllForTableId(), ilBiblEntryFactory\getARInstance(), ilBiblFieldFactory\getARInstance(), ilStudyProgrammeType\getAssignedAdvancedMDRecords(), ilStudyProgrammeType\getAssignedStudyProgrammes(), ilObjOrgUnitTree\getAssignements(), ilOrgUnitUserAssignmentQueries\getAssignmentOrFail(), ilObjStudyProgramme\getAssignmentsOf(), ilOrgUnitUserAssignmentQueries\getAssignmentsOfUserId(), ilObjStudyProgramme\getAssignmentsRaw(), ilBiblAttributeFactory\getAttributesForEntry(), ILIAS\BackgroundTasks\Implementation\Persistence\BasicPersistence\getBucketIdsByState(), ILIAS\BackgroundTasks\Implementation\Persistence\BasicPersistence\getBucketIdsOfUser(), ILIAS\BackgroundTasks\Implementation\Persistence\BasicPersistence\getBucketMetaOfUser(), ilBiblFieldFilterFactory\getByObjectIdAndField(), ilBiblTranslationFactory\getCollectionOfTranslationsForField(), ilOrgUnitPosition\getCorePosition(), ilDclTableView\getCountForTableId(), ilOrgUnitPosition\getDependentAuthorities(), ilTermsOfServiceDocumentGUI\getDocumentsByServerRequest(), ilBiblEntryFactory\getEntryById(), ilDclCache\getFieldProperties(), ilDclBaseFieldModel\getFieldSettings(), ilDclTableView\getFieldSettings(), ilDclTableView\getFilterableFieldSettings(), ilBiblDataFactory\getIlBiblDataById(), ilDclTableFieldSetting\getInstance(), ilStudyProgrammeUserProgressDB\getInstanceForAssignment(), ilStudyProgrammeUserProgressDB\getInstancesForAssignment(), ilStudyProgrammeUserAssignment\getInstancesForProgram(), ilStudyProgrammeUserProgressDB\getInstancesForProgram(), ilStudyProgrammeUserProgressDB\getInstancesForUser(), ilStudyProgrammeUserAssignment\getInstancesOfUser(), ilOrgUnitUserAssignmentQueries\getOrgUnitIdsOfUsersPosition(), ilDclTableHelper\getStandardViewsByVisibleTables(), ilOrgUnitPermissionQueries\getTemplateSetForContextName(), ilMMItemRepository\getTopItems(), ilOrgUnitUserAssignmentQueries\getUserAssignmentsOfPosition(), ilOrgUnitUserAssignmentQueries\getUserIdsOfOrgUnit(), ilOrgUnitUserAssignmentQueries\getUserIdsOfOrgUnits(), ilOrgUnitUserAssignmentQueries\getUserIdsOfOrgUnitsInPosition(), ilOrgUnitUserAssignmentQueries\getUserIdsOfOrgUnitsOfUsersPosition(), ilOrgUnitUserAssignmentQueries\getUserIdsOfPosition(), ilOrgUnitUserAssignmentQueries\getUserIdsOfUsersOrgUnitsInPosition(), ilDclTableView\getVisibleFields(), ilOrgUnitPermissionQueries\hasLocalSet(), ilBiblEntryFactory\loadParsedAttributesByEntryId(), ilStudyProgrammeType\loadTranslation(), ilMMItemTranslationTableGUI\parseData(), ilDclCache\preloadFieldProperties(), ilTermsOfServiceSettingsFormGUI\saveObject(), ilObjTermsOfServiceGUI\showMissingDocuments(), and ilOrgUnitPosition\storeAuthorities().

+ Here is the caller graph for this function:

Field Documentation

◆ $ar_safe_read

ActiveRecord::$ar_safe_read = true
protected

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

◆ $connector_container_name

ActiveRecord::$connector_container_name = ''
protected

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

Referenced by getConnectorContainerName(), and setConnectorContainerName().

◆ ACTIVE_RECORD_VERSION

const ActiveRecord::ACTIVE_RECORD_VERSION = '2.0.7'

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


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