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

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 array, and 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  }
Create styles array
The data for the language used.
+ 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(), array, 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  }
Create styles array
The data for the language used.
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().

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

References $name, array, and count().

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  }
if($format !==null) $name
Definition: metadata.php:146
Create styles array
The data for the language used.
+ 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, array, date, 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
if($format !==null) $name
Definition: metadata.php:146
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
Create styles array
The data for the language used.
+ 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.

Referenced by arViewField\__construct().

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

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

602  {
603  $srModelObjectList = new ActiveRecordList(self::getCalledClass());
604  $srModelObjectList->additionalParams($additional_params);
605 
606  return $srModelObjectList;
607  }
Class ActiveRecordList.
+ Here is the call graph for this function:

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

◆ afterObjectLoad()

ActiveRecord::afterObjectLoad ( )

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

Referenced by buildFromArray(), and read().

539  {
540  }
+ 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  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  }
267  arObjectCache::store($this);
268  $this->afterObjectLoad();
269 
270  return $this;
271  }
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 887 of file class.ActiveRecord.php.

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

◆ copy()

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

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

References array, arException\COPY_DESTINATION_ID_EXISTS, and getArFieldList().

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  }
const COPY_DESTINATION_ID_EXISTS
Create styles array
The data for the language used.
Class arException.
+ Here is the call graph for this function:

◆ count()

◆ create()

ActiveRecord::create ( )

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

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

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

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());
516  arObjectCache::store($this);
517  }
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 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  }
Add data(end) s

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

◆ delete()

ActiveRecord::delete ( )

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

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

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

577  {
578  $this->getArConnector()->delete($this);
579  arObjectCache::purge($this);
580  }
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 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.

References arException\RECORD_NOT_FOUND.

Referenced by ilOrgUnitOperationQueries\findById(), ilObjDefReader\handlerBeginTag(), and ilOrgUnitUserAssignmentGUI\index().

652  {
653  $obj = self::find($primary_key, $add_constructor_args);
654  if (is_null($obj)) {
656  }
657 
658  return $obj;
659  }
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 670 of file class.ActiveRecord.php.

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

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

◆ first()

static ActiveRecord::first ( )
static
Returns
ActiveRecord

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

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

841  {
842  $srModelObjectList = new ActiveRecordList(self::getCalledClass());
843 
844  return $srModelObjectList->first();
845  }
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 279 of file class.ActiveRecord.php.

References getArConnector(), and getArFieldList().

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

◆ 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[]

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

Referenced by arConfigFormGUI\getValuesForItem().

819  {
820  $srModelObjectList = new ActiveRecordList(self::getCalledClass());
821 
822  return $srModelObjectList->get();
823  }
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()

ActiveRecord::getArFieldList ( )

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

References $key.

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

915  {
916  $srModelObjectList = new ActiveRecordList(self::getCalledClass());
917 
918  return $srModelObjectList->getArray($key, $values);
919  }
Class ActiveRecordList.
$key
Definition: croninfo.php:18
+ Here is the caller graph for this function:

◆ getArrayForConnector()

ActiveRecord::getArrayForConnector ( )
final
Returns
array

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

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

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

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)
Create styles array
The data for the language used.
+ 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 316 of file class.ActiveRecord.php.

References getArrayForConnector().

317  {
318  return $this->getArrayForConnector();
319  }
+ 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 351 of file class.ActiveRecord.php.

References arCalledClassCache\get().

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

◆ getCollection()

static ActiveRecord::getCollection ( )
static
Returns
ActiveRecordList

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

Referenced by arStorageRecordGUI\index().

852  {
853  $srModelObjectList = new ActiveRecordList(self::getCalledClass());
854 
855  return $srModelObjectList;
856  }
Class ActiveRecordList.
+ Here is the caller graph for this function:

◆ getConnectorContainerName()

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

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

References $connector_container_name.

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

70  {
71  // WILL BE ABSTRACT TO REPLACE returnDbTableName() IN NEXT VERSION
72  if ($this->connector_container_name) {
74  } else {
75  $ar = self::getCalledClass();
76 
77  return $ar::returnDbTableName();
78  }
79  }
+ 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  }
Class ActiveRecordList.

◆ getPrimaryFieldValue()

ActiveRecord::getPrimaryFieldValue ( )
Returns
mixed

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

References arFieldCache\getPrimaryFieldName().

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

Referenced by ilMStListCoursesGUI\getActions().

727  {
728  $srModelObjectList = new ActiveRecordList(self::getCalledClass());
729 
730  return $srModelObjectList->innerjoin($tablename, $on_this, $on_external, $fields, $operator, $both_external);
731  }
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 711 of file class.ActiveRecord.php.

References getConnectorContainerName().

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

References installDatabase().

379  {
380  return $this->installDatabase();
381  }
+ Here is the call graph for this function:

◆ installDatabase()

ActiveRecord::installDatabase ( )
finalprotected
Returns
bool

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

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

Referenced by installConnector().

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  }
Create styles array
The data for the language used.
+ 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 367 of file class.ActiveRecord.php.

Referenced by arConnectorDB\resetDatabase().

368  {
369  return self::getCalledClass()->installDatabase();
370  }
+ 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  }
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 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  }
Class ActiveRecordList.

◆ limit()

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

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

References $end.

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

◆ orderBy()

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

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

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

758  {
759  $srModelObjectList = new ActiveRecordList(self::getCalledClass());
760  $srModelObjectList->orderBy($orderBy, $orderDirection);
761 
762  return $srModelObjectList;
763  }
Class ActiveRecordList.
+ 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  }
Class ActiveRecordList.

◆ read()

ActiveRecord::read ( )
Exceptions
arException

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

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

Referenced by __construct().

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  }
563  arObjectCache::store($this);
564  $this->afterObjectLoad();
565  }
566  }
$records
Definition: simple_test.php:22
static store(ActiveRecord $object)
Create styles array
The data for the language used.
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 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()

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

References store().

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

503  {
504  $this->store();
505  }
+ 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 294 of file class.ActiveRecord.php.

Referenced by getArrayForConnector().

295  {
296  return null;
297  }
+ Here is the caller graph for this function:

◆ store()

ActiveRecord::store ( )

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

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

Referenced by save().

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  }
static getPrimaryFieldName(ActiveRecord $ar)
Create styles array
The data for the language used.
+ 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 399 of file class.ActiveRecord.php.

Referenced by installDatabase().

400  {
401  return self::getCalledClass()->getArConnector()->checkTableExists(self::getCalledClass());
402  }
+ Here is the caller graph for this function:

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

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

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

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

570  {
571  $this->getArConnector()->update($this);
572  arObjectCache::store($this);
573  }
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 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

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

Referenced by buildFromArray(), and read().

307  {
308  return null;
309  }
+ 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 693 of file class.ActiveRecord.php.

Referenced by ilStudyProgrammeUserProgress\__construct(), ilOrgUnitPosition\afterObjectLoad(), ilDclTableView\createFieldSetting(), ilObjOrgUnit\delete(), ilOrgUnitOperationContextQueries\findByName(), ilOrgUnitOperationQueries\findByOperationString(), ilStudyProgrammeType\getAllTypesArray(), ilStudyProgrammeType\getAssignedAdvancedMDRecords(), ilStudyProgrammeType\getAssignedStudyProgrammes(), ilObjOrgUnitTree\getAssignements(), ilOrgUnitUserAssignmentQueries\getAssignmentOrFail(), ilObjStudyProgramme\getAssignmentsOf(), ilOrgUnitUserAssignmentQueries\getAssignmentsOfUserId(), ilObjStudyProgramme\getAssignmentsRaw(), ilStudyProgrammeType\getAvailableAdvancedMDRecords(), ILIAS\BackgroundTasks\Implementation\Persistence\BasicPersistence\getBucketIdsByState(), ILIAS\BackgroundTasks\Implementation\Persistence\BasicPersistence\getBucketIdsOfUser(), ILIAS\BackgroundTasks\Implementation\Persistence\BasicPersistence\getBucketMetaOfUser(), ilOrgUnitPosition\getCorePosition(), ilOrgUnitPosition\getDependentAuthorities(), ilDclCache\getFieldProperties(), ilDclTableView\getFieldSettings(), ilDclBaseFieldModel\getFieldSettings(), ilDclTableView\getFilterableFieldSettings(), ilStudyProgrammeUserProgressDB\getInstanceForAssignment(), ilStudyProgrammeUserProgressDB\getInstancesForAssignment(), ilStudyProgrammeUserAssignment\getInstancesForProgram(), ilStudyProgrammeUserProgressDB\getInstancesForProgram(), ilStudyProgrammeUserProgressDB\getInstancesForUser(), ilStudyProgrammeUserAssignment\getInstancesOfUser(), ilOrgUnitUserAssignmentQueries\getOrgUnitIdsOfUsersPosition(), ilDclTableHelper\getStandardViewsByVisibleTables(), ilOrgUnitPermissionQueries\getTemplateSetForContextName(), 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(), ilStudyProgrammeType\loadTranslation(), ilDclCache\preloadFieldProperties(), ilOrgUnitOperationQueries\registerNewOperationForMultipleContexts(), ILIAS\BackgroundTasks\Implementation\Persistence\BasicPersistence\saveTask(), ilOrgUnitPathStorage\store(), and ilOrgUnitPosition\storeAuthorities().

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