Class ActiveRecord.
More...
|
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) |
|
◆ __construct()
ActiveRecord::__construct |
( |
|
$primary_key = 0 , |
|
|
arConnector |
$connector = null |
|
) |
| |
- Parameters
-
Definition at line 110 of file class.ActiveRecord.php.
References arFieldCache\get(), read(), and arConnectorMap\register().
111 if ($connector == null) {
118 $key = $arFieldList->getPrimaryFieldName();
119 $this->{$key} = $primary_key;
120 if ($primary_key !== 0 AND $primary_key !== null AND $primary_key !==
false) {
static register(ActiveRecord $ar, arConnector $connector)
static get(ActiveRecord $ar)
◆ __asArray()
ActiveRecord::__asArray |
( |
| ) |
|
◆ __asCsv()
ActiveRecord::__asCsv |
( |
|
$separator = ';' , |
|
|
|
$header = false |
|
) |
| |
- Parameters
-
string | $separator | |
bool | $header | |
- Returns
- string
Definition at line 162 of file class.ActiveRecord.php.
References $header, __asArray(), array, getArFieldList(), and serializeToCSV().
165 $line .= implode($separator, array_keys($this->
getArFieldList()->getRawFields()));
169 foreach ($this->
__asArray() as $field_name => $value) {
171 if ($serialized === null) {
172 $array[$field_name] = $this->{$field_name};
174 $array[$field_name] = $serialized;
177 $line .= implode($separator, array_values($array));
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.
◆ __asSerializedObject()
ActiveRecord::__asSerializedObject |
( |
| ) |
|
◆ __asStdClass()
ActiveRecord::__asStdClass |
( |
| ) |
|
◆ __call()
ActiveRecord::__call |
( |
|
$name, |
|
|
|
$arguments |
|
) |
| |
- Parameters
-
- Returns
- array
Definition at line 862 of file class.ActiveRecord.php.
References array, and count().
864 if (preg_match(
"/get([a-zA-Z]*)/u", $name, $matches) AND
count($arguments) == 0) {
865 return $this->{self::fromCamelCase($matches[1])};
868 if (preg_match(
"/set([a-zA-Z]*)/u", $name, $matches) AND
count($arguments) == 1) {
869 $this->{self::fromCamelCase($matches[1])} = $arguments[0];
871 if (preg_match(
"/findBy([a-zA-Z]*)/u", $name, $matches) AND
count($arguments) == 1) {
872 return self::where(
array( self::fromCamelCase($matches[1]) => $arguments[0] ))->getFirst();
Create styles array
The data for the language used.
◆ __getConvertedDateFieldsAsArray()
ActiveRecord::__getConvertedDateFieldsAsArray |
( |
|
$format = null | ) |
|
- Parameters
-
- Returns
- array
Definition at line 136 of file class.ActiveRecord.php.
References array, date, and getArFieldList().
137 $converted_dates =
array();
139 if ($field->isDateField()) {
140 $name = $field->getName();
141 $value = $this->{$name};
142 $converted_dates[$name] =
array(
143 'unformatted' => $value,
144 'unix' => strtotime($value),
147 $converted_dates[$name][
'formatted'] =
date($format, strtotime($value));
152 return $converted_dates;
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
Create styles array
The data for the language used.
◆ _toCamelCase()
static ActiveRecord::_toCamelCase |
( |
|
$str, |
|
|
|
$capitalise_first_char = false |
|
) |
| |
|
static |
- Parameters
-
string | $str | |
bool | $capitalise_first_char | |
- Returns
- string
Definition at line 883 of file class.ActiveRecord.php.
Referenced by arViewField\__construct().
884 if ($capitalise_first_char) {
885 $str[0] = strtoupper($str[0]);
887 $func = create_function(
'$c',
'return strtoupper($c[1]);');
889 return preg_replace_callback(
'/_([a-z])/', $func, $str);
◆ additionalParams()
static ActiveRecord::additionalParams |
( |
array |
$additional_params | ) |
|
|
static |
◆ affectedRows()
static ActiveRecord::affectedRows |
( |
| ) |
|
|
static |
◆ afterObjectLoad()
ActiveRecord::afterObjectLoad |
( |
| ) |
|
◆ buildFromArray()
ActiveRecord::buildFromArray |
( |
array |
$array | ) |
|
◆ connector()
static ActiveRecord::connector |
( |
arConnector |
$connector | ) |
|
|
static |
◆ copy()
ActiveRecord::copy |
( |
|
$new_id = 0 | ) |
|
◆ count()
static ActiveRecord::count |
( |
| ) |
|
|
static |
◆ create()
◆ dateFormat()
static ActiveRecord::dateFormat |
( |
|
$date_format = 'd.m.Y - H:i:s' | ) |
|
|
static |
- Parameters
-
- Returns
- ActiveRecordList
Definition at line 716 of file class.ActiveRecord.php.
717 $srModelObjectList = new ActiveRecordList(self::getCalledClass()); 718 $srModelObjectList->dateFormat($date_format); 720 return $srModelObjectList;
◆ debug()
static ActiveRecord::debug |
( |
| ) |
|
|
static |
◆ delete()
◆ fieldExists()
static ActiveRecord::fieldExists |
( |
|
$field_name | ) |
|
|
staticfinal |
- Parameters
-
- Returns
- bool
Definition at line 384 of file class.ActiveRecord.php.
385 return self::getCalledClass()->getArConnector()->checkFieldExists(self::getCalledClass(), $field_name);
◆ findOrFail()
static ActiveRecord::findOrFail |
( |
|
$primary_key, |
|
|
array |
$add_constructor_args = array() |
|
) |
| |
|
static |
◆ findOrGetInstance()
static ActiveRecord::findOrGetInstance |
( |
|
$primary_key, |
|
|
array |
$add_constructor_args = array() |
|
) |
| |
|
static |
- Parameters
-
| $primary_key | |
array | $add_constructor_args | 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 621 of file class.ActiveRecord.php.
Referenced by ilDclTableViewGUI\executeCommand().
622 $obj = self::find($primary_key, $add_constructor_args);
626 $class_name = get_called_class();
627 $obj = arFactory::getInstance($class_name, 0, $add_constructor_args);
628 $obj->setPrimaryFieldValue($primary_key);
630 $obj->storeObjectToCache();
◆ first()
static ActiveRecord::first |
( |
| ) |
|
|
static |
◆ fixDateField()
ActiveRecord::fixDateField |
( |
|
$field_name, |
|
|
|
$value |
|
) |
| |
◆ flushDB()
static ActiveRecord::flushDB |
( |
| ) |
|
|
staticfinal |
◆ fromCamelCase()
static ActiveRecord::fromCamelCase |
( |
|
$str | ) |
|
|
staticprotected |
- Parameters
-
- Returns
- string
Definition at line 898 of file class.ActiveRecord.php.
899 $str[0] = strtolower($str[0]);
900 $func = create_function(
'$c',
'return "_" . strtolower($c[1]);');
902 return preg_replace_callback(
'/([A-Z])/', $func, $str);
◆ get()
static ActiveRecord::get |
( |
| ) |
|
|
static |
◆ getArConnector()
ActiveRecord::getArConnector |
( |
| ) |
|
◆ getArFieldList()
ActiveRecord::getArFieldList |
( |
| ) |
|
- Returns
Definition at line 48 of file class.ActiveRecord.php.
References arFieldCache\get().
Referenced by __asArray(), __asCsv(), __asStdClass(), __getConvertedDateFieldsAsArray(), arWhere\asSQLStatement(), buildFromArray(), copy(), create(), fixDateField(), getArrayForConnector(), arConnectorDB\installDatabase(), installDatabase(), arStorage\mapFromActiveRecord(), arStorage\mapToActiveRecord(), arConnectorDB\updateDatabase(), and arConnectorDB\updateIndices().
static get(ActiveRecord $ar)
◆ getArray()
static ActiveRecord::getArray |
( |
|
$key = null , |
|
|
|
$values = null |
|
) |
| |
|
static |
◆ getArrayForConnector()
ActiveRecord::getArrayForConnector |
( |
| ) |
|
|
final |
- Returns
- array
Definition at line 305 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().
308 $field_name = $field->getName();
309 $sleeped = $this->
sleep($field_name);
310 $var = ($sleeped === null) ? ($this->{$field_name}) : $sleeped;
311 $data[$field_name] =
array( $field->getFieldType(), $var );
Create styles array
The data for the language used.
◆ getArrayForDb()
ActiveRecord::getArrayForDb |
( |
| ) |
|
|
final |
◆ getCalledClass()
static ActiveRecord::getCalledClass |
( |
| ) |
|
|
staticprotected |
◆ getCollection()
static ActiveRecord::getCollection |
( |
| ) |
|
|
static |
◆ getConnectorContainerName()
ActiveRecord::getConnectorContainerName |
( |
| ) |
|
- Returns
- string Return the Name of your Connector Table
Definition at line 66 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().
68 if ($this->connector_container_name) {
71 $ar = self::getCalledClass();
73 return $ar::returnDbTableName();
$connector_container_name
◆ getFirstFromLastQuery()
static ActiveRecord::getFirstFromLastQuery |
( |
| ) |
|
|
static |
◆ getPrimaryFieldValue()
ActiveRecord::getPrimaryFieldValue |
( |
| ) |
|
◆ 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 674 of file class.ActiveRecord.php.
677 return $srModelObjectList->innerjoin($tablename, $on_this, $on_external, $fields, $operator, $both_external);
◆ innerjoinAR()
static ActiveRecord::innerjoinAR |
( |
ActiveRecord |
$ar, |
|
|
|
$on_this, |
|
|
|
$on_external, |
|
|
|
$fields = array( '*' ) , |
|
|
|
$operator = '=' , |
|
|
|
$both_external = false |
|
) |
| |
|
static |
◆ installConnector()
ActiveRecord::installConnector |
( |
| ) |
|
◆ installDatabase()
ActiveRecord::installDatabase |
( |
| ) |
|
|
finalprotected |
◆ 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 345 of file class.ActiveRecord.php.
Referenced by arConnectorDB\resetDatabase().
346 return self::getCalledClass()->installDatabase();
◆ last()
static ActiveRecord::last |
( |
| ) |
|
|
static |
◆ 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 690 of file class.ActiveRecord.php.
693 return $srModelObjectList->leftjoin($tablename, $on_this, $on_external, $fields, $operator, $both_external);
◆ limit()
static ActiveRecord::limit |
( |
|
$start, |
|
|
|
$end |
|
) |
| |
|
static |
◆ orderBy()
static ActiveRecord::orderBy |
( |
|
$orderBy, |
|
|
|
$orderDirection = 'ASC' |
|
) |
| |
|
static |
◆ preloadObjects()
static ActiveRecord::preloadObjects |
( |
| ) |
|
|
static |
◆ raw()
static ActiveRecord::raw |
( |
|
$set_raw = true | ) |
|
|
static |
◆ read()
Definition at line 505 of file class.ActiveRecord.php.
References $records, afterObjectLoad(), count(), getArConnector(), getArrayForConnector(), getPrimaryFieldValue(), arException\RECORD_NOT_FOUND, arObjectCache\store(), and wakeUp().
Referenced by __construct().
509 } elseif (
count(
$records) == 0 AND $this->ar_safe_read ==
false) {
510 $this->is_new =
true;
514 if ($this->
wakeUp($k, $rec->{$k}) === null) {
515 $this->{$k} = $rec->{$k};
517 $this->{$k} = $this->
wakeUp($k, $rec->{$k});
static store(ActiveRecord $object)
wakeUp($field_name, $field_value)
◆ removeDBField()
static ActiveRecord::removeDBField |
( |
|
$field_name | ) |
|
|
staticfinal |
- Parameters
-
- Returns
- bool
Definition at line 394 of file class.ActiveRecord.php.
395 return self::getCalledClass()->getArConnector()->removeField(self::getCalledClass(), $field_name);
◆ renameDBField()
static ActiveRecord::renameDBField |
( |
|
$old_name, |
|
|
|
$new_name |
|
) |
| |
|
staticfinal |
- Parameters
-
- Returns
- bool
Definition at line 366 of file class.ActiveRecord.php.
367 return self::getCalledClass()->getArConnector()->renameField(self::getCalledClass(), $old_name, $new_name);
◆ resetDB()
static ActiveRecord::resetDB |
( |
| ) |
|
|
staticfinal |
- Returns
- bool
Definition at line 433 of file class.ActiveRecord.php.
434 return self::getCalledClass()->getArConnector()->resetDatabase(self::getCalledClass());
◆ returnDbTableName()
static ActiveRecord::returnDbTableName |
( |
| ) |
|
|
static |
◆ save()
◆ 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
-
- Returns
- mixed
Definition at line 191 of file class.ActiveRecord.php.
Referenced by __asCsv().
◆ setConnectorContainerName()
ActiveRecord::setConnectorContainerName |
( |
|
$connector_container_name | ) |
|
◆ setPrimaryFieldValue()
ActiveRecord::setPrimaryFieldValue |
( |
|
$value | ) |
|
◆ sleep()
ActiveRecord::sleep |
( |
|
$field_name | ) |
|
◆ store()
◆ storeObjectToCache()
ActiveRecord::storeObjectToCache |
( |
| ) |
|
◆ tableExists()
static ActiveRecord::tableExists |
( |
| ) |
|
|
staticfinal |
◆ truncateDB()
static ActiveRecord::truncateDB |
( |
| ) |
|
|
staticfinal |
- Returns
- bool
Definition at line 441 of file class.ActiveRecord.php.
442 return self::getCalledClass()->getArConnector()->truncateDatabase(self::getCalledClass());
◆ update()
◆ updateDB()
static ActiveRecord::updateDB |
( |
| ) |
|
|
staticfinal |
- Returns
- bool
Definition at line 419 of file class.ActiveRecord.php.
420 if (!self::tableExists()) {
421 self::getCalledClass()->installDatabase();
426 return self::getCalledClass()->getArConnector()->updateDatabase(self::getCalledClass());
◆ wakeUp()
ActiveRecord::wakeUp |
( |
|
$field_name, |
|
|
|
$field_value |
|
) |
| |
◆ where()
static ActiveRecord::where |
( |
|
$where, |
|
|
|
$operator = null |
|
) |
| |
|
static |
- Parameters
-
- Returns
- ActiveRecordList
Definition at line 643 of file class.ActiveRecord.php.
Referenced by ilStudyProgrammeUserProgress\__construct(), ilDclTableView\createFieldSetting(), ilStudyProgrammeType\getAllTypesArray(), ilStudyProgrammeType\getAssignedAdvancedMDRecords(), ilStudyProgrammeType\getAssignedStudyProgrammes(), ilObjStudyProgramme\getAssignmentsOf(), ilObjStudyProgramme\getAssignmentsRaw(), ilStudyProgrammeType\getAvailableAdvancedMDRecords(), ilDclCache\getFieldProperties(), ilDclTableView\getFieldSettings(), ilDclBaseFieldModel\getFieldSettings(), ilDclTableView\getFilterableFieldSettings(), ilStudyProgrammeUserProgress\getInstanceForAssignment(), ilStudyProgrammeUserProgress\getInstancesForAssignment(), ilStudyProgrammeUserAssignment\getInstancesForProgram(), ilStudyProgrammeUserProgress\getInstancesForProgram(), ilStudyProgrammeUserProgress\getInstancesForUser(), ilStudyProgrammeUserAssignment\getInstancesOfUser(), ilDclTableHelper\getStandardViewsByVisibleTables(), ilStudyProgrammeType\getTranslation(), ilStudyProgrammeType\getTranslations(), ilDclTableView\getVisibleFields(), ilStudyProgrammeType\loadTranslation(), ilDclCache\preloadFieldProperties(), and ilOrgUnitPathStorage\store().
645 $srModelObjectList->where($where, $operator);
647 return $srModelObjectList;
◆ $ar_safe_read
ActiveRecord::$ar_safe_read = true |
|
protected |
◆ $connector_container_name
ActiveRecord::$connector_container_name = '' |
|
protected |
◆ ACTIVE_RECORD_VERSION
const ActiveRecord::ACTIVE_RECORD_VERSION = '2.0.7' |
The documentation for this class was generated from the following file: