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 118 of file class.ActiveRecord.php.
References arFieldCache\get(), read(), and arConnectorMap\register().
119 if($connector == NULL) {
127 $key = $arFieldList->getPrimaryFieldName();
128 $this->{$key} = $primary_key;
129 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 171 of file class.ActiveRecord.php.
References $separator, __asArray(), getArFieldList(), and serializeToCSV().
178 foreach ($this->
__asArray() as $field_name => $value) {
180 if ($serialized === NULL) {
181 $array[$field_name] = $this->{$field_name};
183 $array[$field_name] = $serialized;
186 $line .= implode(
$separator, array_values($array));
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 855 of file class.ActiveRecord.php.
References count().
857 if (preg_match(
"/get([a-zA-Z]*)/u", $name, $matches) AND
count($arguments) == 0) {
858 return $this->{self::fromCamelCase($matches[1])};
861 if (preg_match(
"/set([a-zA-Z]*)/u", $name, $matches) AND
count($arguments) == 1) {
862 $this->{self::fromCamelCase($matches[1])} = $arguments[0];
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();
◆ __getConvertedDateFieldsAsArray()
ActiveRecord::__getConvertedDateFieldsAsArray |
( |
|
$format = NULL | ) |
|
- Parameters
-
- Returns
- array
Definition at line 145 of file class.ActiveRecord.php.
References getArFieldList().
146 $converted_dates = array();
148 if ($field->isDateField()) {
149 $name = $field->getName();
150 $value = $this->{$name};
151 $converted_dates[$name] = array(
152 'unformatted' => $value,
153 'unix' => strtotime($value),
156 $converted_dates[$name][
'formatted'] = date($format, strtotime($value));
161 return $converted_dates;
◆ _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().
877 if ($capitalise_first_char) {
878 $str[0] = strtoupper($str[0]);
880 $func = create_function(
'$c',
'return strtoupper($c[1]);');
882 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 709 of file class.ActiveRecord.php.
710 $srModelObjectList = new ActiveRecordList(self::getCalledClass()); 711 $srModelObjectList->dateFormat($date_format); 713 return $srModelObjectList;
◆ debug()
static ActiveRecord::debug |
( |
| ) |
|
|
static |
◆ delete()
◆ fieldExists()
static ActiveRecord::fieldExists |
( |
|
$field_name | ) |
|
|
staticfinal |
- Parameters
-
- Returns
- bool
Definition at line 381 of file class.ActiveRecord.php.
382 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 614 of file class.ActiveRecord.php.
615 $obj = self::find($primary_key, $add_constructor_args);
619 $class_name = get_called_class();
620 $obj = arFactory::getInstance($class_name, 0, $add_constructor_args);
621 $obj->setPrimaryFieldValue($primary_key);
623 $obj->storeObjectToCache();
◆ first()
static ActiveRecord::first |
( |
| ) |
|
|
static |
◆ flushDB()
static ActiveRecord::flushDB |
( |
| ) |
|
|
staticfinal |
◆ fromCamelCase()
static ActiveRecord::fromCamelCase |
( |
|
$str | ) |
|
|
staticprotected |
- Parameters
-
- Returns
- string
Definition at line 891 of file class.ActiveRecord.php.
892 $str[0] = strtolower($str[0]);
893 $func = create_function(
'$c',
'return "_" . strtolower($c[1]);');
895 return preg_replace_callback(
'/([A-Z])/', $func, $str);
◆ get()
static ActiveRecord::get |
( |
| ) |
|
|
static |
◆ getArConnector()
ActiveRecord::getArConnector |
( |
| ) |
|
◆ 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().
static get(ActiveRecord $ar)
◆ getArray()
static ActiveRecord::getArray |
( |
|
$key = NULL , |
|
|
|
$values = NULL |
|
) |
| |
|
static |
- Parameters
-
- Returns
- array
Definition at line 840 of file class.ActiveRecord.php.
843 return $srModelObjectList->getArray($key, $values);
◆ 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().
303 $field_name = $field->getName();
304 if ($this->
sleep($field_name) === NULL) {
305 $data[$field_name] = array( $field->getFieldType(), $this->{$field_name} );
307 $data[$field_name] = array( $field->getFieldType(), $this->
sleep($field_name) );
◆ 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 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().
76 if ($this->connector_container_name) {
79 $ar = self::getCalledClass();
81 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 667 of file class.ActiveRecord.php.
670 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 342 of file class.ActiveRecord.php.
Referenced by arConnectorDB\resetDatabase().
343 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 683 of file class.ActiveRecord.php.
686 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 |
- Parameters
-
| $orderBy | |
string | $orderDirection | |
- Returns
- ActiveRecordList
Definition at line 696 of file class.ActiveRecord.php.
698 $srModelObjectList->orderBy($orderBy, $orderDirection);
700 return $srModelObjectList;
◆ preloadObjects()
static ActiveRecord::preloadObjects |
( |
| ) |
|
|
static |
◆ raw()
static ActiveRecord::raw |
( |
|
$set_raw = true | ) |
|
|
static |
◆ 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().
502 } elseif (
count(
$records) == 0 AND $this->ar_safe_read ==
false) {
503 $this->is_new =
true;
507 if ($this->
wakeUp($k, $rec->{$k}) === NULL) {
508 $this->{$k} = $rec->{$k};
510 $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 391 of file class.ActiveRecord.php.
392 return self::getCalledClass()->getArConnector()->removeField(self::getCalledClass(), $field_name);
◆ renameDBField()
static ActiveRecord::renameDBField |
( |
|
$old_name, |
|
|
|
$new_name |
|
) |
| |
|
staticfinal |
- Parameters
-
- Returns
- bool
Definition at line 363 of file class.ActiveRecord.php.
364 return self::getCalledClass()->getArConnector()->renameField(self::getCalledClass(), $old_name, $new_name);
◆ resetDB()
static ActiveRecord::resetDB |
( |
| ) |
|
|
staticfinal |
- Returns
- bool
Definition at line 430 of file class.ActiveRecord.php.
431 return self::getCalledClass()->getArConnector()->resetDatabase(self::getCalledClass());
◆ returnDbTableName()
static ActiveRecord::returnDbTableName |
( |
| ) |
|
|
staticabstract |
◆ 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 200 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 438 of file class.ActiveRecord.php.
439 return self::getCalledClass()->getArConnector()->truncateDatabase(self::getCalledClass());
◆ update()
◆ updateDB()
static ActiveRecord::updateDB |
( |
| ) |
|
|
staticfinal |
- Returns
- bool
Definition at line 416 of file class.ActiveRecord.php.
417 if (! self::tableExists()) {
418 self::getCalledClass()->installDatabase();
423 return self::getCalledClass()->getArConnector()->updateDatabase(self::getCalledClass());
◆ wakeUp()
ActiveRecord::wakeUp |
( |
|
$field_name, |
|
|
|
$field_value |
|
) |
| |
◆ where()
static ActiveRecord::where |
( |
|
$where, |
|
|
|
$operator = NULL |
|
) |
| |
|
static |
◆ $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: