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

Constructor & Destructor Documentation

◆ __construct()

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

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

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

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

References getArFieldList().

Referenced by __asCsv().

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  }
+ 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.

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

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

References getArFieldList().

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

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  }
+ 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.

References $name, and count().

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

◆ __getConvertedDateFieldsAsArray()

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

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

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

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

References $c.

Referenced by arViewField\__construct().

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  }
+ 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.

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

596  {
597  $srModelObjectList = new ActiveRecordList(self::getCalledClass());
598  $srModelObjectList->additionalParams($additional_params);
599 
600  return $srModelObjectList;
601  }
Class ActiveRecordList.
+ Here is the call graph for this function:

◆ 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  }
Class ActiveRecordList.

◆ afterObjectLoad()

ActiveRecord::afterObjectLoad ( )

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

Referenced by buildFromArray(), and read().

536  {
537  }
+ Here is the caller graph for this function:

◆ buildFromArray()

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

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

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

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  }
264  arObjectCache::store($this);
265  $this->afterObjectLoad();
266 
267  return $this;
268  }
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
Parameters
arConnector$connector
Returns
ActiveRecordList

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

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

◆ copy()

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

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

References arException\COPY_DESTINATION_ID_EXISTS, and getArFieldList().

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

◆ count()

◆ create()

ActiveRecord::create ( )

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

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

Referenced by ilTermsOfServiceDocument\buildFromArray(), ilDclTableViewFieldSetting\cloneStructure(), ilDclTableView\cloneStructure(), ilStudyProgrammeType\getAllTypesArray(), ilOrgUnitPathStorage\store(), and store().

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());
513  arObjectCache::store($this);
514  }
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 (   $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  }
Class ActiveRecordList.

◆ delete()

ActiveRecord::delete ( )

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

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

Referenced by ILIAS\BackgroundTasks\Implementation\Persistence\BasicPersistence\getValueContainerId(), and arObjectCache\purge().

571  {
572  $this->getArConnector()->delete($this);
573  arObjectCache::purge($this);
574  }
static purge(ActiveRecord $object)
+ 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.

References arException\RECORD_NOT_FOUND.

Referenced by ilBiblFieldFilterFactory\findById(), ilBiblLibraryFactory\findById(), ilOrgUnitOperationQueries\findById(), ilBiblTranslationFactory\findById(), ilBiblFieldFactory\getType(), ilObjDefReader\handlerBeginTag(), and ilOrgUnitUserAssignmentGUI\index().

646  {
647  $obj = self::find($primary_key, $add_constructor_args);
648  if (is_null($obj)) {
650  }
651 
652  return $obj;
653  }
Class arException.
+ 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_argsReturns 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.

Referenced by ilDclTableViewGUI\executeCommand(), ilOrgUnitPositionFormGUI\fillForm(), and ilOrgUnitPositionGUI\getPositionFromRequest().

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

◆ first()

static ActiveRecord::first ( )
static
Returns
ActiveRecord

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

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

835  {
836  $srModelObjectList = new ActiveRecordList(self::getCalledClass());
837 
838  return $srModelObjectList->first();
839  }
Class ActiveRecordList.
+ 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.

References getArConnector(), and getArFieldList().

277  {
278  if ($this->getArFieldList()->getFieldByName($field_name)->isDateField()) {
279  return $this->getArConnector()->fixDate($value);
280  }
281 
282  return $value;
283  }
+ Here is the call graph for this function:

◆ flushDB()

static ActiveRecord::flushDB ( )
staticfinal
Returns
bool

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

Referenced by ilMMTopItemGUI\restore().

479  {
480  return self::truncateDB();
481  }
+ 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.

References $c.

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  }

◆ get()

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

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

Referenced by ilGSProviderFactory\appendPlugins(), ilBiblLibraryFactory\getAll(), and arConfigFormGUI\getValuesForItem().

813  {
814  $srModelObjectList = new ActiveRecordList(self::getCalledClass());
815 
816  return $srModelObjectList->get();
817  }
Class ActiveRecordList.
+ Here is the caller graph for this function:

◆ getArConnector()

ActiveRecord::getArConnector ( )
Returns

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

References arConnectorMap\get().

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

41  {
42  return arConnectorMap::get($this);
43  }
static get(ActiveRecord $ar)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getArFieldList()

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

References $key, and $values.

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

909  {
910  $srModelObjectList = new ActiveRecordList(self::getCalledClass());
911 
912  return $srModelObjectList->getArray($key, $values);
913  }
Class ActiveRecordList.
$values
$key
Definition: croninfo.php:18
+ Here is the caller graph for this function:

◆ getArrayForConnector()

ActiveRecord::getArrayForConnector ( )
final
Returns
array

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

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

Referenced by arConnectorDB\create(), create(), getArrayForDb(), arStorage\mapFromActiveRecord(), arStorage\mapToActiveRecord(), read(), and arConnectorDB\update().

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

◆ getArrayForDb()

ActiveRecord::getArrayForDb ( )
final
Returns
array
Deprecated:

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

References getArrayForConnector().

314  {
315  return $this->getArrayForConnector();
316  }
+ Here is the call graph for this function:

◆ getCalledClass()

static ActiveRecord::getCalledClass ( )
staticprotected
Returns
ActiveRecord

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

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

References arCalledClassCache\get().

349  {
350  $class = get_called_class();
351 
352  return arCalledClassCache::get($class);
353  }
+ Here is the call graph for this function:

◆ getCollection()

static ActiveRecord::getCollection ( )
static
Returns
ActiveRecordList

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

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

846  {
847  $srModelObjectList = new ActiveRecordList(self::getCalledClass());
848 
849  return $srModelObjectList;
850  }
Class ActiveRecordList.
+ 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  }
Class ActiveRecordList.

◆ getPrimaryFieldValue()

ActiveRecord::getPrimaryFieldValue ( )
Returns
mixed

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

95  {
96  $primary_fieldname = arFieldCache::getPrimaryFieldName($this);
97 
98  return $this->{$primary_fieldname};
99  }
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,
  $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.

Referenced by ilMStListCoursesGUI\getActions().

721  {
722  $srModelObjectList = new ActiveRecordList(self::getCalledClass());
723 
724  return $srModelObjectList->innerjoin($tablename, $on_this, $on_external, $fields, $operator, $both_external);
725  }
Class ActiveRecordList.
+ 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.

References getConnectorContainerName().

706  {
707  return self::innerjoin($ar->getConnectorContainerName(), $on_this, $on_external, $fields, $operator, $both_external);
708  }
+ 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.

References installDatabase().

376  {
377  return $this->installDatabase();
378  }
+ Here is the call graph for this function:

◆ installDatabase()

ActiveRecord::installDatabase ( )
finalprotected
Returns
bool

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

References getArConnector(), getArFieldList(), and tableExists().

Referenced by installConnector().

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

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

Referenced by arConnectorDB\resetDatabase().

365  {
366  return self::getCalledClass()->installDatabase();
367  }
+ 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  }
Class ActiveRecordList.

◆ 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  }
Class ActiveRecordList.

◆ limit()

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

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

References $end, and $start.

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

◆ orderBy()

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

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

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

752  {
753  $srModelObjectList = new ActiveRecordList(self::getCalledClass());
754  $srModelObjectList->orderBy($orderBy, $orderDirection);
755 
756  return $srModelObjectList;
757  }
Class ActiveRecordList.
+ Here is the caller graph for this function:

◆ preloadObjects()

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

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

References ILIAS\GlobalScreen\get().

585  {
586  return self::get();
587  }
get(string $class_name)
+ 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  }
Class ActiveRecordList.

◆ read()

ActiveRecord::read ( )
Exceptions
arException

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

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

Referenced by __construct().

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  }
557  arObjectCache::store($this);
558  $this->afterObjectLoad();
559  }
560  }
$records
Definition: simple_test.php:22
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 (   $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()

static ActiveRecord::returnDbTableName ( )
static
Exceptions

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

References arException\UNKNONWN_EXCEPTION.

60  {
61  throw new arException(arException::UNKNONWN_EXCEPTION, 'Implement getConnectorContainerName in your child-class');
62  }
const UNKNONWN_EXCEPTION
Class arException.

◆ save()

ActiveRecord::save ( )

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

References store().

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

500  {
501  $this->store();
502  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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

Referenced by __asCsv().

203  {
204  return null;
205  }
+ 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.

References $connector_container_name.

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

◆ setPrimaryFieldValue()

ActiveRecord::setPrimaryFieldValue (   $value)
Parameters
$value

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

References arFieldCache\getPrimaryFieldName().

106  {
107  $primary_fieldname = arFieldCache::getPrimaryFieldName($this);
108 
109  $this->{$primary_fieldname} = $value;
110  }
static getPrimaryFieldName(ActiveRecord $ar)
+ Here is the call graph for this function:

◆ sleep()

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

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

Referenced by getArrayForConnector().

292  {
293  return null;
294  }
+ Here is the caller graph for this function:

◆ store()

ActiveRecord::store ( )

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

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

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

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

References arObjectCache\store().

135  {
136  arObjectCache::store($this);
137  }
static store(ActiveRecord $object)
+ Here is the call graph for this function:

◆ tableExists()

static ActiveRecord::tableExists ( )
staticfinal
Returns
bool

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

Referenced by installDatabase().

397  {
398  return self::getCalledClass()->getArConnector()->checkTableExists(self::getCalledClass());
399  }
+ Here is the caller graph for this function:

◆ 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 ( )

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

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

Referenced by ilTermsOfServiceDocument\buildFromArray(), ilStudyProgrammeType\getAllTypesArray(), ilOrgUnitPathStorage\store(), and store().

564  {
565  $this->getArConnector()->update($this);
566  arObjectCache::store($this);
567  }
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
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

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

Referenced by buildFromArray(), and read().

304  {
305  return null;
306  }
+ Here is the caller graph for this function:

◆ where()

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

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

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

688  {
689  $srModelObjectList = new ActiveRecordList(self::getCalledClass());
690  $srModelObjectList->where($where, $operator);
691 
692  return $srModelObjectList;
693  }
Class ActiveRecordList.
+ 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: