ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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

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

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

931 {
932 // Getter
933 if (preg_match("/get([a-zA-Z]*)/u", $name, $matches) and count($arguments) == 0) {
934 return $this->{self::fromCamelCase($matches[1])};
935 }
936 // Setter
937 if (preg_match("/set([a-zA-Z]*)/u", $name, $matches) and count($arguments) == 1) {
938 $this->{self::fromCamelCase($matches[1])} = $arguments[0];
939 }
940 if (preg_match("/findBy([a-zA-Z]*)/u", $name, $matches) and count($arguments) == 1) {
941 return self::where(array( self::fromCamelCase($matches[1]) => $arguments[0] ))->getFirst();
942 }
943 }
static where($where, $operator=null)
static fromCamelCase($str)
if($format !==null) $name
Definition: metadata.php:146

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 }
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
$format
Definition: metadata.php:141

References $format, $name, date, 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 952 of file class.ActiveRecord.php.

953 {
954 if ($capitalise_first_char) {
955 $str[0] = strtoupper($str[0]);
956 }
957 $func = create_function('$c', 'return strtoupper($c[1]);');
958
959 return preg_replace_callback('/_([a-z])/', $func, $str);
960 }

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

602 {
603 $srModelObjectList = new ActiveRecordList(self::getCalledClass());
604 $srModelObjectList->additionalParams($additional_params);
605
606 return $srModelObjectList;
607 }
Class ActiveRecordList.

◆ affectedRows()

static ActiveRecord::affectedRows ( )
static
Returns
int

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

799 {
800 $srModelObjectList = new ActiveRecordList(self::getCalledClass());
801
802 return $srModelObjectList->affectedRows();
803 }

◆ afterObjectLoad()

ActiveRecord::afterObjectLoad ( )

Reimplemented in ilDclFieldProperty, ilOrgUnitPosition, and ilOrgUnitPermission.

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

539 {
540 }

◆ buildFromArray()

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

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 if ($this->wakeUp($field_name, $value) === null) {
262 $this->{$field_name} = $value;
263 } else {
264 $this->{$field_name} = $this->wakeUp($field_name, $value);
265 }
266 }
268 $this->afterObjectLoad();
269
270 return $this;
271 }
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

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

888 {
889 $srModelObjectList = new ActiveRecordList(self::getCalledClass());
890
891 return $srModelObjectList->connector($connector);
892 }

◆ copy()

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

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

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

References arException\COPY_DESTINATION_ID_EXISTS.

◆ count()

static ActiveRecord::count ( )
static
Returns
int

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

810 {
811 return self::affectedRows();
812 }

Referenced by 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, and arStorage.

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

509 {
510 if ($this->getArFieldList()->getPrimaryField()->getSequence()) {
511 $primary_fieldname = arFieldCache::getPrimaryFieldName($this);
512 $this->{$primary_fieldname} = $this->getArConnector()->nextID($this);
513 }
514
515 $this->getArConnector()->create($this, $this->getArrayForConnector());
517 }
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 771 of file class.ActiveRecord.php.

771 :i:s')
772 {
773 $srModelObjectList = new ActiveRecordList(self::getCalledClass());
774 $srModelObjectList->dateFormat($date_format);
775
776 return $srModelObjectList;
777 }

◆ debug()

static ActiveRecord::debug ( )
static
Returns
ActiveRecordList

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

830 {
831 $srModelObjectList = new ActiveRecordList(self::getCalledClass());
832
833 return $srModelObjectList->debug();
834 }

◆ delete()

ActiveRecord::delete ( )

Reimplemented in ilDclTableView, ilOrgUnitPosition, and ilOrgUnitPermission.

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

577 {
578 $this->getArConnector()->delete($this);
580 }
static purge(ActiveRecord $object)

References arObjectCache\purge().

+ Here is the call graph for this function:

◆ fieldExists()

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

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

411 {
412 return self::getCalledClass()->getArConnector()->checkFieldExists(self::getCalledClass(), $field_name);
413 }

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

652 {
653 $obj = self::find($primary_key, $add_constructor_args);
654 if (is_null($obj)) {
656 }
657
658 return $obj;
659 }

References arException\RECORD_NOT_FOUND.

Referenced by 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 670 of file class.ActiveRecord.php.

671 {
672 $obj = self::find($primary_key, $add_constructor_args);
673 if ($obj !== null) {
674 return $obj;
675 } else {
676 $class_name = get_called_class();
677 $obj = arFactory::getInstance($class_name, 0, $add_constructor_args);
678 $obj->setPrimaryFieldValue($primary_key);
679 $obj->is_new = true;
680 $obj->storeObjectToCache();
681
682 return $obj;
683 }
684 }

Referenced by ilDclTableViewGUI\executeCommand().

+ Here is the caller graph for this function:

◆ first()

static ActiveRecord::first ( )
static
Returns
ActiveRecord

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

841 {
842 $srModelObjectList = new ActiveRecordList(self::getCalledClass());
843
844 return $srModelObjectList->first();
845 }

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

280 {
281 if ($this->getArFieldList()->getFieldByName($field_name)->isDateField()) {
282 return $this->getArConnector()->fixDate($value);
283 }
284
285 return $value;
286 }

◆ flushDB()

static ActiveRecord::flushDB ( )
staticfinal
Returns
bool

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

482 {
483 return self::truncateDB();
484 }

◆ fromCamelCase()

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

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

969 {
970 $str[0] = strtolower($str[0]);
971 $func = create_function('$c', 'return "_" . strtolower($c[1]);');
972
973 return preg_replace_callback('/([A-Z])/', $func, $str);
974 }

◆ get()

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

Reimplemented in ilOrgUnitPosition.

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

819 {
820 $srModelObjectList = new ActiveRecordList(self::getCalledClass());
821
822 return $srModelObjectList->get();
823 }

Referenced by ilBibliographicSetting\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(), 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 914 of file class.ActiveRecord.php.

915 {
916 $srModelObjectList = new ActiveRecordList(self::getCalledClass());
917
918 return $srModelObjectList->getArray($key, $values);
919 }

References $key.

Referenced by 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 325 of file class.ActiveRecord.php.

326 {
327 $data = array();
328 foreach ($this->getArFieldList()->getFields() as $field) {
329 $field_name = $field->getName();
330 $sleeped = $this->sleep($field_name);
331 $var = ($sleeped === null) ? ($this->{$field_name}) : $sleeped;
332 $data[$field_name] = array( $field->getFieldType(), $var );
333 }
334
335 return $data;
336 }
sleep($field_name)

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

317 {
318 return $this->getArrayForConnector();
319 }

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

352 {
353 $class = get_called_class();
354
355 return arCalledClassCache::get($class);
356 }

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

852 {
853 $srModelObjectList = new ActiveRecordList(self::getCalledClass());
854
855 return $srModelObjectList;
856 }

Referenced by arStorageRecordGUI\index().

+ Here is the caller graph for this function:

◆ getConnectorContainerName()

ActiveRecord::getConnectorContainerName ( )
Returns
string @description Return the Name of your Connector Table

Reimplemented in ilBibliographicSetting, ilOrgUnitPathStorage, arMixedKey, and ilADTActiveRecordWrapper.

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

70 {
71 // WILL BE ABSTRACT TO REPLACE returnDbTableName() IN NEXT VERSION
72 if ($this->connector_container_name) {
74 } else {
76
77 return $ar::returnDbTableName();
78 }
79 }

References $connector_container_name, and getCalledClass().

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

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

◆ getFirstFromLastQuery()

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

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

875 {
876 $srModelObjectList = new ActiveRecordList(self::getCalledClass());
877
878 return $srModelObjectList->getFirstFromLastQuery();
879 }

◆ 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(), arObjectCache\purge(), arConnectorDB\read(), arConnectorSession\read(), arObjectCache\store(), 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 726 of file class.ActiveRecord.php.

727 {
728 $srModelObjectList = new ActiveRecordList(self::getCalledClass());
729
730 return $srModelObjectList->innerjoin($tablename, $on_this, $on_external, $fields, $operator, $both_external);
731 }

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

712 {
713 return self::innerjoin($ar->getConnectorContainerName(), $on_this, $on_external, $fields, $operator, $both_external);
714 }
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 378 of file class.ActiveRecord.php.

379 {
380 return $this->installDatabase();
381 }

◆ installDatabase()

ActiveRecord::installDatabase ( )
finalprotected
Returns
bool

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

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

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

368 {
369 return self::getCalledClass()->installDatabase();
370 }

Referenced by arConnectorDB\resetDatabase().

+ Here is the caller graph for this function:

◆ last()

static ActiveRecord::last ( )
static
Returns
ActiveRecord

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

863 {
864 $srModelObjectList = new ActiveRecordList(self::getCalledClass());
865
866 return $srModelObjectList->last();
867 }

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

744 {
745 $srModelObjectList = new ActiveRecordList(self::getCalledClass());
746
747 return $srModelObjectList->leftjoin($tablename, $on_this, $on_external, $fields, $operator, $both_external);
748 }

◆ limit()

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

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

787 {
788 $srModelObjectList = new ActiveRecordList(self::getCalledClass());
789 $srModelObjectList->limit($start, $end);
790
791 return $srModelObjectList;
792 }
$end
Definition: saml1-acs.php:18

References $end.

◆ orderBy()

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

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

758 {
759 $srModelObjectList = new ActiveRecordList(self::getCalledClass());
760 $srModelObjectList->orderBy($orderBy, $orderDirection);
761
762 return $srModelObjectList;
763 }

Referenced by ilDclTableView\createOrGetStandardView(), ilOrgUnitPathStorage\getTextRepresentationOfOrgUnits(), and ilDclSelectionOption\getValues().

+ Here is the caller graph for this function:

◆ preloadObjects()

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

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

591 {
592 return self::get();
593 }

◆ raw()

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

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

901 {
902 $srModelObjectList = new ActiveRecordList(self::getCalledClass());
903
904 return $srModelObjectList->raw($set_raw);
905 }

◆ read()

ActiveRecord::read ( )
Exceptions
arException

Reimplemented in arStorage.

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

547 {
548 $records = $this->getArConnector()->read($this);
549 if (is_array($records) && count($records) === 0 && $this->ar_safe_read === true) {
551 } elseif (is_array($records) && count($records) === 0 && $this->ar_safe_read === false) {
552 $this->is_new = true;
553 }
554 $records = is_array($records) ? $records : array();
555 foreach ($records as $rec) {
556 foreach ($this->getArrayForConnector() as $k => $v) {
557 if ($this->wakeUp($k, $rec->{$k}) === null) {
558 $this->{$k} = $rec->{$k};
559 } else {
560 $this->{$k} = $this->wakeUp($k, $rec->{$k});
561 }
562 }
564 $this->afterObjectLoad();
565 }
566 }
$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 421 of file class.ActiveRecord.php.

422 {
423 return self::getCalledClass()->getArConnector()->removeField(self::getCalledClass(), $field_name);
424 }

◆ renameDBField()

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

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

391 {
392 return self::getCalledClass()->getArConnector()->renameField(self::getCalledClass(), $old_name, $new_name);
393 }

◆ resetDB()

static ActiveRecord::resetDB ( )
staticfinal
Returns
bool

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

464 {
465 return self::getCalledClass()->getArConnector()->resetDatabase(self::getCalledClass());
466 }

◆ returnDbTableName()

◆ save()

ActiveRecord::save ( )

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

503 {
504 $this->store();
505 }

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

295 {
296 return null;
297 }

◆ store()

ActiveRecord::store ( )

Reimplemented in ilOrgUnitPathStorage.

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

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

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

+ Here is the call graph for this function:

◆ storeObjectToCache()

ActiveRecord::storeObjectToCache ( )

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

400 {
401 return self::getCalledClass()->getArConnector()->checkTableExists(self::getCalledClass());
402 }

◆ truncateDB()

static ActiveRecord::truncateDB ( )
staticfinal
Returns
bool

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

473 {
474 return self::getCalledClass()->getArConnector()->truncateDatabase(self::getCalledClass());
475 }

◆ update()

ActiveRecord::update ( )

Reimplemented in ilDclFieldProperty, ilOrgUnitPosition, ilOrgUnitPermission, and arStorage.

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

570 {
571 $this->getArConnector()->update($this);
573 }

References arObjectCache\store().

Referenced by 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 448 of file class.ActiveRecord.php.

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

◆ wakeUp()

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

Reimplemented in ilDclTableView, ilDclTableViewFieldSetting, ilOrgUnitPermission, and ilADTActiveRecordWrapper.

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

307 {
308 return null;
309 }

◆ where()

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

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

694 {
695 $srModelObjectList = new ActiveRecordList(self::getCalledClass());
696 $srModelObjectList->where($where, $operator);
697
698 return $srModelObjectList;
699 }

Referenced by ilStudyProgrammeUserProgress\__construct(), ilOrgUnitPosition\afterObjectLoad(), ilDclTableView\createFieldSetting(), ilObjOrgUnit\delete(), ilStudyProgrammeTypeTranslation\deleteAllTranslations(), ilOrgUnitOperationContextQueries\findByName(), ilOrgUnitOperationQueries\findByOperationString(), ilOrgUnitUserAssignment\findOrCreateAssignment(), ilDclSelectionOption\getAllForField(), ilDclTableView\getAllForTableId(), ilStudyProgrammeType\getAssignedAdvancedMDRecords(), ilStudyProgrammeType\getAssignedStudyProgrammes(), ilObjOrgUnitTree\getAssignements(), ilOrgUnitUserAssignmentQueries\getAssignmentOrFail(), ilObjStudyProgramme\getAssignmentsOf(), ilOrgUnitUserAssignmentQueries\getAssignmentsOfUserId(), ilObjStudyProgramme\getAssignmentsRaw(), ILIAS\BackgroundTasks\Implementation\Persistence\BasicPersistence\getBucketIdsByState(), ILIAS\BackgroundTasks\Implementation\Persistence\BasicPersistence\getBucketIdsOfUser(), ILIAS\BackgroundTasks\Implementation\Persistence\BasicPersistence\getBucketMetaOfUser(), ilOrgUnitPosition\getCorePosition(), ilDclTableView\getCountForTableId(), ilOrgUnitPosition\getDependentAuthorities(), ilDclCache\getFieldProperties(), ilDclBaseFieldModel\getFieldSettings(), ilDclTableView\getFieldSettings(), ilDclTableView\getFilterableFieldSettings(), ilDclTableFieldSetting\getInstance(), ilStudyProgrammeUserProgressDB\getInstanceForAssignment(), ilStudyProgrammeUserProgressDB\getInstancesForAssignment(), ilStudyProgrammeUserAssignment\getInstancesForProgram(), ilStudyProgrammeUserProgressDB\getInstancesForProgram(), ilStudyProgrammeUserProgressDB\getInstancesForUser(), ilStudyProgrammeUserAssignment\getInstancesOfUser(), ilOrgUnitUserAssignmentQueries\getOrgUnitIdsOfUsersPosition(), ilDclTableHelper\getStandardViewsByVisibleTables(), ilOrgUnitPermissionQueries\getTemplateSetForContextName(), ilOrgUnitUserAssignmentQueries\getUserAssignmentsOfPosition(), ilOrgUnitUserAssignmentQueries\getUserIdsOfOrgUnit(), ilOrgUnitUserAssignmentQueries\getUserIdsOfOrgUnits(), ilOrgUnitUserAssignmentQueries\getUserIdsOfOrgUnitsInPosition(), ilOrgUnitUserAssignmentQueries\getUserIdsOfOrgUnitsOfUsersPosition(), ilOrgUnitUserAssignmentQueries\getUserIdsOfPosition(), ilOrgUnitUserAssignmentQueries\getUserIdsOfUsersOrgUnitsInPosition(), ilDclTableView\getVisibleFields(), ilOrgUnitPermissionQueries\hasLocalSet(), ilStudyProgrammeType\loadTranslation(), ilDclCache\preloadFieldProperties(), 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: