ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f87
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)
 
 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 118 of file class.ActiveRecord.php.

References arFieldCache\get(), read(), and arConnectorMap\register().

118  {
119  if($connector == NULL) {
120  $connector = new arConnectorDB();
121  }
122  //$this->arConnector = $connector;
123  arConnectorMap::register($this, $connector);
124 
125  $arFieldList = arFieldCache::get($this);
126  //$this->arFieldList = $arFieldList ;
127  $key = $arFieldList->getPrimaryFieldName();
128  $this->{$key} = $primary_key;
129  if ($primary_key !== 0 AND $primary_key !== NULL AND $primary_key !== false) {
130  $this->read();
131  }
132  }
Class arConnectorDB.
static register(ActiveRecord $ar, arConnector $connector)
static get(ActiveRecord $ar)
+ Here is the call graph for this function:

Member Function Documentation

◆ __asArray()

ActiveRecord::__asArray ( )
Returns
array

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

References getArFieldList().

Referenced by __asCsv().

208  {
209  $return = array();
210  foreach ($this->getArFieldList()->getFields() as $field) {
211  $fieldname = $field->getName();
212  $return[$fieldname] = $this->{$fieldname};
213  }
214 
215  return $return;
216  }
+ 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 171 of file class.ActiveRecord.php.

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

171  {
172  $line = '';
173  if ($header) {
174  $line .= implode($separator, array_keys($this->getArFieldList()->getRawFields()));
175  $line .= "\n";
176  }
177  $array = array();
178  foreach ($this->__asArray() as $field_name => $value) {
179  $serialized = $this->serializeToCSV($field_name);
180  if ($serialized === NULL) {
181  $array[$field_name] = $this->{$field_name};
182  } else {
183  $array[$field_name] = $serialized;
184  }
185  }
186  $line .= implode($separator, array_values($array));
187 
188  return $line;
189  }
$separator
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 236 of file class.ActiveRecord.php.

236  {
237  return serialize($this);
238  }

◆ __asStdClass()

ActiveRecord::__asStdClass ( )
Returns
stdClass

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

References getArFieldList().

Referenced by arConnectorSession\create().

222  {
223  $return = new stdClass();
224  foreach ($this->getArFieldList()->getFields() as $field) {
225  $fieldname = $field->getName();
226  $return->{$fieldname} = $this->{$fieldname};
227  }
228 
229  return $return;
230  }
+ 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 855 of file class.ActiveRecord.php.

References count().

855  {
856  // Getter
857  if (preg_match("/get([a-zA-Z]*)/u", $name, $matches) AND count($arguments) == 0) {
858  return $this->{self::fromCamelCase($matches[1])};
859  }
860  // Setter
861  if (preg_match("/set([a-zA-Z]*)/u", $name, $matches) AND count($arguments) == 1) {
862  $this->{self::fromCamelCase($matches[1])} = $arguments[0];
863  }
864  if (preg_match("/findBy([a-zA-Z]*)/u", $name, $matches) AND count($arguments) == 1) {
865  return self::where(array( self::fromCamelCase($matches[1]) => $arguments[0] ))->getFirst();
866  }
867  }
+ 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 getArFieldList().

145  {
146  $converted_dates = array();
147  foreach ($this->getArFieldList()->getFields() as $field) {
148  if ($field->isDateField()) {
149  $name = $field->getName();
150  $value = $this->{$name};
151  $converted_dates[$name] = array(
152  'unformatted' => $value,
153  'unix' => strtotime($value),
154  );
155  if ($format) {
156  $converted_dates[$name]['formatted'] = date($format, strtotime($value));
157  }
158  }
159  }
160 
161  return $converted_dates;
162  }
+ 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 876 of file class.ActiveRecord.php.

Referenced by arViewField\__construct().

876  {
877  if ($capitalise_first_char) {
878  $str[0] = strtoupper($str[0]);
879  }
880  $func = create_function('$c', 'return strtoupper($c[1]);');
881 
882  return preg_replace_callback('/_([a-z])/', $func, $str);
883  }
+ 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 548 of file class.ActiveRecord.php.

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

548  {
549  $srModelObjectList = new ActiveRecordList(self::getCalledClass());
550  $srModelObjectList->additionalParams($additional_params);
551 
552  return $srModelObjectList;
553  }
Class ActiveRecordList.
+ Here is the call graph for this function:

◆ affectedRows()

static ActiveRecord::affectedRows ( )
static
Returns
int

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

734  {
735  $srModelObjectList = new ActiveRecordList(self::getCalledClass());
736 
737  return $srModelObjectList->affectedRows();
738  }
Class ActiveRecordList.

◆ afterObjectLoad()

ActiveRecord::afterObjectLoad ( )

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

Referenced by buildFromArray(), and read().

494  {
495  }
+ Here is the caller graph for this function:

◆ buildFromArray()

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

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

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

246  {
247  $class = get_class($this);
248  $primary = $this->getArFieldList()->getPrimaryFieldName();
249  $primary_value = $array[$primary];
250  if ($primary_value AND arObjectCache::isCached($class, $primary_value)) {
251  return arObjectCache::get($class, $primary_value);
252  }
253  foreach ($array as $field_name => $value) {
254  if ($this->wakeUp($field_name, $value) === NULL) {
255  $this->{$field_name} = $value;
256  } else {
257  $this->{$field_name} = $this->wakeUp($field_name, $value);
258  }
259  }
260  arObjectCache::store($this);
261  $this->afterObjectLoad();
262 
263  return $this;
264  }
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 815 of file class.ActiveRecord.php.

815  {
816  $srModelObjectList = new ActiveRecordList(self::getCalledClass());
817 
818  return $srModelObjectList->connector($connector);
819  }
Class ActiveRecordList.

◆ copy()

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

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

References arException\COPY_DESTINATION_ID_EXISTS, and getArFieldList().

483  {
484  if (self::where(array( $this->getArFieldList()->getPrimaryFieldName() => $new_id ))->hasSets()) {
486  }
487  $new_obj = clone($this);
488  $new_obj->setPrimaryFieldValue($new_id);
489 
490  return $new_obj;
491  }
const COPY_DESTINATION_ID_EXISTS
Class arException.
+ Here is the call graph for this function:

◆ count()

static ActiveRecord::count ( )
static
Returns
int

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

Referenced by __call(), and read().

744  {
745  return self::affectedRows();
746  }
+ Here is the caller graph for this function:

◆ create()

ActiveRecord::create ( )

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

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

Referenced by store().

467  {
468  if ($this->getArFieldList()->getPrimaryField()->getSequence()) {
469  $this->id = $this->getArConnector()->nextID($this);
470  }
471 
472  $this->getArConnector()->create($this, $this->getArrayForConnector());
473  arObjectCache::store($this);
474  }
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 709 of file class.ActiveRecord.php.

709  :i:s') {
710  $srModelObjectList = new ActiveRecordList(self::getCalledClass());
711  $srModelObjectList->dateFormat($date_format);
712 
713  return $srModelObjectList;
714  }

◆ debug()

static ActiveRecord::debug ( )
static
Returns
ActiveRecordList

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

762  {
763  $srModelObjectList = new ActiveRecordList(self::getCalledClass());
764 
765  return $srModelObjectList->debug();
766  }
Class ActiveRecordList.

◆ delete()

ActiveRecord::delete ( )

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

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

525  {
526  $this->getArConnector()->delete($this);
527  arObjectCache::purge($this);
528  }
static purge(ActiveRecord $object)
+ Here is the call graph for this function:

◆ fieldExists()

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

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

381  {
382  return self::getCalledClass()->getArConnector()->checkFieldExists(self::getCalledClass(), $field_name);
383  }

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

References arException\RECORD_NOT_FOUND.

596  {
597  $obj = self::find($primary_key, $add_constructor_args);
598  if (is_null($obj)) {
600  }
601 
602  return $obj;
603  }
Class arException.

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

614  {
615  $obj = self::find($primary_key, $add_constructor_args);
616  if ($obj !== NULL) {
617  return $obj;
618  } else {
619  $class_name = get_called_class();
620  $obj = arFactory::getInstance($class_name, 0, $add_constructor_args);
621  $obj->setPrimaryFieldValue($primary_key);
622  $obj->is_new = true;
623  $obj->storeObjectToCache();
624 
625  return $obj;
626  }
627  }

◆ first()

static ActiveRecord::first ( )
static
Returns
ActiveRecord

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

772  {
773  $srModelObjectList = new ActiveRecordList(self::getCalledClass());
774 
775  return $srModelObjectList->first();
776  }
Class ActiveRecordList.

◆ flushDB()

static ActiveRecord::flushDB ( )
staticfinal
Returns
bool

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

446  {
447  return self::truncateDB();
448  }

◆ fromCamelCase()

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

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

891  {
892  $str[0] = strtolower($str[0]);
893  $func = create_function('$c', 'return "_" . strtolower($c[1]);');
894 
895  return preg_replace_callback('/([A-Z])/', $func, $str);
896  }

◆ get()

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

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

Referenced by arConfigFormGUI\getValuesForItem().

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

◆ getArConnector()

ActiveRecord::getArConnector ( )
Returns

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

References arConnectorMap\get().

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

47  {
48  return arConnectorMap::get($this);
49  //return $this->arConnector;
50  }
static get(ActiveRecord $ar)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getArFieldList()

ActiveRecord::getArFieldList ( )
Returns

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

References arFieldCache\get(), and returnDbTableName().

Referenced by __asArray(), __asCsv(), __asStdClass(), __getConvertedDateFieldsAsArray(), arWhere\asSQLStatement(), buildFromArray(), copy(), create(), getArrayForConnector(), arConnectorDB\installDatabase(), installDatabase(), arStorage\mapFromActiveRecord(), arStorage\mapToActiveRecord(), arConnectorDB\updateDatabase(), and arConnectorDB\updateIndices().

56  {
57  return arFieldCache::get($this);
58  // return $this->arFieldList;
59  }
static get(ActiveRecord $ar)
+ 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 840 of file class.ActiveRecord.php.

840  {
841  $srModelObjectList = new ActiveRecordList(self::getCalledClass());
842 
843  return $srModelObjectList->getArray($key, $values);
844  }
Class ActiveRecordList.

◆ getArrayForConnector()

ActiveRecord::getArrayForConnector ( )
final
Returns
array

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

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

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

300  {
301  $data = array();
302  foreach ($this->getArFieldList()->getFields() as $field) {
303  $field_name = $field->getName();
304  if ($this->sleep($field_name) === NULL) {
305  $data[$field_name] = array( $field->getFieldType(), $this->{$field_name} );
306  } else {
307  $data[$field_name] = array( $field->getFieldType(), $this->sleep($field_name) );
308  }
309  }
310 
311  return $data;
312  }
sleep($field_name)
+ 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 292 of file class.ActiveRecord.php.

References getArrayForConnector().

292  {
293  return $this->getArrayForConnector();
294  }
+ 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 327 of file class.ActiveRecord.php.

References arCalledClassCache\get().

327  {
328  $class = get_called_class();
329 
330  return arCalledClassCache::get($class);
331  }
+ Here is the call graph for this function:

◆ getCollection()

static ActiveRecord::getCollection ( )
static
Returns
ActiveRecordList

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

Referenced by arStorageRecordGUI\index().

782  {
783  $srModelObjectList = new ActiveRecordList(self::getCalledClass());
784 
785  return $srModelObjectList;
786  }
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 74 of file class.ActiveRecord.php.

References $connector_container_name.

Referenced by ActiveRecordList\__construct(), arWhere\asSQLStatement(), arJoin\asSQLStatement(), 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().

74  {
75  // WILL BE ABSTRACT TO REPLACE returnDbTableName() IN NEXT VERSION
76  if ($this->connector_container_name) {
78  } else {
79  $ar = self::getCalledClass();
80 
81  return $ar::returnDbTableName();
82  }
83  }
+ Here is the caller graph for this function:

◆ getFirstFromLastQuery()

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

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

803  {
804  $srModelObjectList = new ActiveRecordList(self::getCalledClass());
805 
806  return $srModelObjectList->getFirstFromLastQuery();
807  }
Class ActiveRecordList.

◆ getPrimaryFieldValue()

ActiveRecord::getPrimaryFieldValue ( )
Returns
mixed

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

References arFieldCache\getPrimaryFieldName().

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

97  {
98  $primary_fieldname = arFieldCache::getPrimaryFieldName($this);
99 
100  return $this->{$primary_fieldname};
101  }
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 667 of file class.ActiveRecord.php.

667  {
668  $srModelObjectList = new ActiveRecordList(self::getCalledClass());
669 
670  return $srModelObjectList->innerjoin($tablename, $on_this, $on_external, $fields, $operator, $both_external);
671  }
Class ActiveRecordList.

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

References getConnectorContainerName().

653  {
654  return self::innerjoin($ar->getConnectorContainerName(), $on_this, $on_external, $fields, $operator, $both_external);
655  }
+ Here is the call graph for this function:

◆ installConnector()

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

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

References installDatabase().

352  {
353  return $this->installDatabase();
354  }
+ Here is the call graph for this function:

◆ installDatabase()

ActiveRecord::installDatabase ( )
finalprotected
Returns
bool

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

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

Referenced by installConnector().

399  {
400  if (! $this->tableExists()) {
401  $fields = array();
402  foreach ($this->getArFieldList()->getFields() as $field) {
403  $fields[$field->getName()] = $field->getAttributesForConnector();
404  }
405 
406  return $this->getArConnector()->installDatabase($this, $fields);
407  } else {
408  return $this->getArConnector()->updateDatabase($this);
409  }
410  }
+ 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 342 of file class.ActiveRecord.php.

Referenced by arConnectorDB\resetDatabase().

342  {
343  return self::getCalledClass()->installDatabase();
344  }
+ Here is the caller graph for this function:

◆ last()

static ActiveRecord::last ( )
static
Returns
ActiveRecord

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

792  {
793  $srModelObjectList = new ActiveRecordList(self::getCalledClass());
794 
795  return $srModelObjectList->last();
796  }
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 683 of file class.ActiveRecord.php.

683  {
684  $srModelObjectList = new ActiveRecordList(self::getCalledClass());
685 
686  return $srModelObjectList->leftjoin($tablename, $on_this, $on_external, $fields, $operator, $both_external);
687  }
Class ActiveRecordList.

◆ limit()

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

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

723  {
724  $srModelObjectList = new ActiveRecordList(self::getCalledClass());
725  $srModelObjectList->limit($start, $end);
726 
727  return $srModelObjectList;
728  }
Class ActiveRecordList.

◆ orderBy()

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

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

696  {
697  $srModelObjectList = new ActiveRecordList(self::getCalledClass());
698  $srModelObjectList->orderBy($orderBy, $orderDirection);
699 
700  return $srModelObjectList;
701  }
Class ActiveRecordList.

◆ preloadObjects()

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

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

538  {
539  return self::get();
540  }

◆ raw()

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

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

827  {
828  $srModelObjectList = new ActiveRecordList(self::getCalledClass());
829 
830  return $srModelObjectList->raw($set_raw);
831  }
Class ActiveRecordList.

◆ read()

ActiveRecord::read ( )

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

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

Referenced by __construct().

498  {
499  $records = $this->getArConnector()->read($this);
500  if (count($records) == 0 AND $this->ar_safe_read == true) {
502  } elseif (count($records) == 0 AND $this->ar_safe_read == false) {
503  $this->is_new = true;
504  }
505  foreach ($records as $rec) {
506  foreach ($this->getArrayForConnector() as $k => $v) {
507  if ($this->wakeUp($k, $rec->{$k}) === NULL) {
508  $this->{$k} = $rec->{$k};
509  } else {
510  $this->{$k} = $this->wakeUp($k, $rec->{$k});
511  }
512  }
513  arObjectCache::store($this);
514  $this->afterObjectLoad();
515  }
516  }
$records
Definition: simple_test.php:17
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 391 of file class.ActiveRecord.php.

391  {
392  return self::getCalledClass()->getArConnector()->removeField(self::getCalledClass(), $field_name);
393  }

◆ renameDBField()

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

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

363  {
364  return self::getCalledClass()->getArConnector()->renameField(self::getCalledClass(), $old_name, $new_name);
365  }

◆ resetDB()

static ActiveRecord::resetDB ( )
staticfinal
Returns
bool

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

430  {
431  return self::getCalledClass()->getArConnector()->resetDatabase(self::getCalledClass());
432  }

◆ returnDbTableName()

static ActiveRecord::returnDbTableName ( )
staticabstract
Returns
string Return the Name of your Database Table
Deprecated:

Referenced by getArFieldList().

+ Here is the caller graph for this function:

◆ save()

ActiveRecord::save ( )

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

References store().

462  {
463  $this->store();
464  }
+ Here is the call 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 200 of file class.ActiveRecord.php.

Referenced by __asCsv().

200  {
201  return NULL;
202  }
+ Here is the caller graph for this function:

◆ setConnectorContainerName()

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

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

References $connector_container_name.

89  {
90  $this->connector_container_name = $connector_container_name;
91  }

◆ setPrimaryFieldValue()

ActiveRecord::setPrimaryFieldValue (   $value)
Parameters
$value

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

References arFieldCache\getPrimaryFieldName().

107  {
108  $primary_fieldname = arFieldCache::getPrimaryFieldName($this);
109 
110  $this->{$primary_fieldname} = $value;
111  }
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 272 of file class.ActiveRecord.php.

Referenced by getArrayForConnector().

272  {
273  return NULL;
274  }
+ Here is the caller graph for this function:

◆ store()

ActiveRecord::store ( )

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

References create(), and update().

Referenced by save().

453  {
454  if (! $this->getId()) {
455  $this->create();
456  } else {
457  $this->update();
458  }
459  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ storeObjectToCache()

ActiveRecord::storeObjectToCache ( )

Definition at line 135 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 371 of file class.ActiveRecord.php.

Referenced by installDatabase().

371  {
372  return self::getCalledClass()->getArConnector()->checkTableExists(self::getCalledClass());
373  }
+ Here is the caller graph for this function:

◆ truncateDB()

static ActiveRecord::truncateDB ( )
staticfinal
Returns
bool

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

438  {
439  return self::getCalledClass()->getArConnector()->truncateDatabase(self::getCalledClass());
440  }

◆ update()

ActiveRecord::update ( )

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

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

Referenced by store().

519  {
520  $this->getArConnector()->update($this);
521  arObjectCache::store($this);
522  }
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 416 of file class.ActiveRecord.php.

416  {
417  if (! self::tableExists()) {
418  self::getCalledClass()->installDatabase();
419 
420  return true;
421  }
422 
423  return self::getCalledClass()->getArConnector()->updateDatabase(self::getCalledClass());
424  }

◆ wakeUp()

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

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

Referenced by buildFromArray(), and read().

283  {
284  return NULL;
285  }
+ 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 636 of file class.ActiveRecord.php.

636  {
637  $srModelObjectList = new ActiveRecordList(self::getCalledClass());
638  $srModelObjectList->where($where, $operator);
639 
640  return $srModelObjectList;
641  }
Class ActiveRecordList.

Field Documentation

◆ $ar_safe_read

ActiveRecord::$ar_safe_read = true
protected

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

◆ $connector_container_name

ActiveRecord::$connector_container_name = ''
protected

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

Referenced by getConnectorContainerName(), and setConnectorContainerName().

◆ ACTIVE_RECORD_VERSION

const ActiveRecord::ACTIVE_RECORD_VERSION = '2.0.7'

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


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