ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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

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

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)

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

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

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 }

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

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 }
serializeToCSV($field)
This method is called for every field of your instance if you use __asCsv.
$header
$separator

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

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

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 }

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

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 }
static fromCamelCase($str)
static where($where, $operator=NULL)

◆ __getConvertedDateFieldsAsArray()

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

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

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 }

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

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 }

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

548 {
549 $srModelObjectList = new ActiveRecordList(self::getCalledClass());
550 $srModelObjectList->additionalParams($additional_params);
551
552 return $srModelObjectList;
553 }
Class ActiveRecordList.

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

◆ afterObjectLoad()

ActiveRecord::afterObjectLoad ( )

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

494 {
495 }

◆ buildFromArray()

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

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

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 }
261 $this->afterObjectLoad();
262
263 return $this;
264 }
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 815 of file class.ActiveRecord.php.

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

◆ copy()

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

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

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 }
Class arException.
const COPY_DESTINATION_ID_EXISTS

References arException\COPY_DESTINATION_ID_EXISTS.

◆ count()

static ActiveRecord::count ( )
static
Returns
int

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

744 {
745 return self::affectedRows();
746 }

Referenced by ilStudyProgrammeType\loadTranslation(), and ilStudyProgrammeType\processAndStoreIconFile().

+ Here is the caller graph for this function:

◆ create()

ActiveRecord::create ( )

Reimplemented in arStorage.

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

467 {
468 if ($this->getArFieldList()->getPrimaryField()->getSequence()) {
469 $this->id = $this->getArConnector()->nextID($this);
470 }
471
472 $this->getArConnector()->create($this, $this->getArrayForConnector());
474 }

References arObjectCache\store().

+ Here is the call 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 }

◆ delete()

ActiveRecord::delete ( )

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

525 {
526 $this->getArConnector()->delete($this);
528 }
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 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.

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

References arException\RECORD_NOT_FOUND.

Referenced by 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 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 }

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

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

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

47 {
48 return arConnectorMap::get($this);
49 //return $this->arConnector;
50 }
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 56 of file class.ActiveRecord.php.

56 {
57 return arFieldCache::get($this);
58 // return $this->arFieldList;
59 }

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

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

Referenced by ilMemcacheServerTableGUI\parseData().

+ Here is the caller graph for this function:

◆ getArrayForConnector()

ActiveRecord::getArrayForConnector ( )
final
Returns
array

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

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)
$data

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

292 {
293 return $this->getArrayForConnector();
294 }

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

327 {
328 $class = get_called_class();
329
330 return arCalledClassCache::get($class);
331 }

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

782 {
783 $srModelObjectList = new ActiveRecordList(self::getCalledClass());
784
785 return $srModelObjectList;
786 }

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, arMixedKey, and ilADTActiveRecordWrapper.

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

74 {
75 // WILL BE ABSTRACT TO REPLACE returnDbTableName() IN NEXT VERSION
76 if ($this->connector_container_name) {
78 } else {
80
81 return $ar::returnDbTableName();
82 }
83 }

References $connector_container_name, and getCalledClass().

Referenced by arJoin\asSQLStatement(), arWhere\asSQLStatement(), 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 803 of file class.ActiveRecord.php.

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

◆ getPrimaryFieldValue()

ActiveRecord::getPrimaryFieldValue ( )
Returns
mixed

Reimplemented in ilADTActiveRecordWrapper.

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

97 {
98 $primary_fieldname = arFieldCache::getPrimaryFieldName($this);
99
100 return $this->{$primary_fieldname};
101 }
static getPrimaryFieldName(ActiveRecord $ar)

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

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

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

352 {
353 return $this->installDatabase();
354 }

◆ installDatabase()

ActiveRecord::installDatabase ( )
finalprotected
Returns
bool

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

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 }

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

342 {
343 return self::getCalledClass()->installDatabase();
344 }

Referenced by arConnectorDB\resetDatabase().

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

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

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

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

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

◆ read()

ActiveRecord::read ( )

Reimplemented in arStorage.

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

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 }
514 $this->afterObjectLoad();
515 }
516 }
$records
Definition: simple_test.php:17

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

◆ save()

ActiveRecord::save ( )

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

462 {
463 $this->store();
464 }

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

200 {
201 return NULL;
202 }

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

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

References $connector_container_name.

◆ setPrimaryFieldValue()

ActiveRecord::setPrimaryFieldValue (   $value)
Parameters
$value

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

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

References arFieldCache\getPrimaryFieldName().

+ Here is the call graph for this function:

◆ sleep()

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

Reimplemented in ilADTActiveRecordWrapper.

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

272 {
273 return NULL;
274 }

◆ store()

ActiveRecord::store ( )

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

453 {
454 if (! $this->getId()) {
455 $this->create();
456 } else {
457 $this->update();
458 }
459 }

◆ storeObjectToCache()

ActiveRecord::storeObjectToCache ( )

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

371 {
372 return self::getCalledClass()->getArConnector()->checkTableExists(self::getCalledClass());
373 }

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

Reimplemented in arStorage.

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

519 {
520 $this->getArConnector()->update($this);
522 }

References arObjectCache\store().

+ Here is the call 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

Reimplemented in ilADTActiveRecordWrapper.

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

283 {
284 return NULL;
285 }

◆ where()

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: