Class ActiveRecord.
More...
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.
|
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) |
Detailed Description
Constructor & Destructor Documentation
ActiveRecord::__construct |
( |
|
$primary_key = 0 , |
|
|
arConnector |
$connector = NULL |
|
) |
| |
- Parameters
-
Definition at line 118 of file class.ActiveRecord.php.
References get(), read(), and arConnectorMap\register().
{
if($connector == NULL) {
}
$key = $arFieldList->getPrimaryFieldName();
$this->{$key} = $primary_key;
if ($primary_key !== 0 AND $primary_key !== NULL AND $primary_key !== false) {
}
}
Member Function Documentation
ActiveRecord::__asArray |
( |
| ) |
|
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().
{
$line = '';
if ($header) {
$line .= "\n";
}
$array = array();
foreach ($this->
__asArray() as $field_name => $value) {
if ($serialized === NULL) {
$array[$field_name] = $this->{$field_name};
} else {
$array[$field_name] = $serialized;
}
}
$line .= implode(
$separator, array_values($array));
return $line;
}
ActiveRecord::__asSerializedObject |
( |
| ) |
|
ActiveRecord::__asStdClass |
( |
| ) |
|
ActiveRecord::__call |
( |
|
$name, |
|
|
|
$arguments |
|
) |
| |
- Parameters
-
- Returns
- array
Definition at line 855 of file class.ActiveRecord.php.
{
if (preg_match(
"/get([a-zA-Z]*)/u", $name, $matches) AND
count($arguments) == 0) {
}
if (preg_match(
"/set([a-zA-Z]*)/u", $name, $matches) AND
count($arguments) == 1) {
}
if (preg_match(
"/findBy([a-zA-Z]*)/u", $name, $matches) AND
count($arguments) == 1) {
return self::where(array( self::fromCamelCase($matches[1]) => $arguments[0] ))->getFirst();
}
}
ActiveRecord::__getConvertedDateFieldsAsArray |
( |
|
$format = NULL | ) |
|
- Parameters
-
- Returns
- array
Definition at line 145 of file class.ActiveRecord.php.
References getArFieldList().
{
$converted_dates = array();
if ($field->isDateField()) {
$name = $field->getName();
$value = $this->{$name};
$converted_dates[$name] = array(
'unformatted' => $value,
'unix' => strtotime($value),
);
if ($format) {
$converted_dates[$name]['formatted'] = date($format, strtotime($value));
}
}
}
return $converted_dates;
}
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().
{
if ($capitalise_first_char) {
$str[0] = strtoupper($str[0]);
}
$func = create_function('$c', 'return strtoupper($c[1]);');
return preg_replace_callback('/_([a-z])/', $func, $str);
}
static ActiveRecord::additionalParams |
( |
array |
$additional_params | ) |
|
|
static |
- Parameters
-
- Returns
- $this
Definition at line 548 of file class.ActiveRecord.php.
{
$srModelObjectList->additionalParams($additional_params);
return $srModelObjectList;
}
static ActiveRecord::affectedRows |
( |
| ) |
|
|
static |
ActiveRecord::afterObjectLoad |
( |
| ) |
|
ActiveRecord::buildFromArray |
( |
array |
$array | ) |
|
static ActiveRecord::connector |
( |
arConnector |
$connector | ) |
|
|
static |
ActiveRecord::copy |
( |
|
$new_id = 0 | ) |
|
static ActiveRecord::count |
( |
| ) |
|
|
static |
static ActiveRecord::dateFormat |
( |
|
$date_format = 'd.m.Y - H:i:s' | ) |
|
|
static |
- Parameters
-
- Returns
- ActiveRecordList
Definition at line 709 of file class.ActiveRecord.php.
:i:s') {
$srModelObjectList = new ActiveRecordList(self::getCalledClass());
$srModelObjectList->dateFormat($date_format);
return $srModelObjectList;
}
static ActiveRecord::debug |
( |
| ) |
|
|
static |
static ActiveRecord::fieldExists |
( |
|
$field_name | ) |
|
|
staticfinal |
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
-
- Returns
- ActiveRecord
Definition at line 596 of file class.ActiveRecord.php.
References arException\RECORD_NOT_FOUND.
{
$obj = self::find($primary_key, $add_constructor_args);
if (is_null($obj)) {
}
return $obj;
}
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.
{
$obj = self::find($primary_key, $add_constructor_args);
if ($obj !== NULL) {
return $obj;
} else {
$class_name = get_called_class();
$obj = arFactory::getInstance($class_name, 0, $add_constructor_args);
$obj->setPrimaryFieldValue($primary_key);
$obj->is_new = true;
$obj->storeObjectToCache();
return $obj;
}
}
static ActiveRecord::first |
( |
| ) |
|
|
static |
static ActiveRecord::flushDB |
( |
| ) |
|
|
staticfinal |
static ActiveRecord::fromCamelCase |
( |
|
$str | ) |
|
|
staticprotected |
- Parameters
-
- Returns
- string
Definition at line 891 of file class.ActiveRecord.php.
{
$str[0] = strtolower($str[0]);
$func = create_function('$c', 'return "_" . strtolower($c[1]);');
return preg_replace_callback('/([A-Z])/', $func, $str);
}
static ActiveRecord::get |
( |
| ) |
|
|
static |
ActiveRecord::getArConnector |
( |
| ) |
|
ActiveRecord::getArFieldList |
( |
| ) |
|
static ActiveRecord::getArray |
( |
|
$key = NULL , |
|
|
|
$values = NULL |
|
) |
| |
|
static |
- Parameters
-
- Returns
- array
Definition at line 840 of file class.ActiveRecord.php.
{
return $srModelObjectList->getArray($key, $values);
}
ActiveRecord::getArrayForConnector |
( |
| ) |
|
|
final |
- Returns
- array
Definition at line 300 of file class.ActiveRecord.php.
Referenced by arConnectorDB\create(), and arConnectorDB\update().
{
$data = array();
$field_name = $field->getName();
if ($this->
sleep($field_name) === NULL) {
$data[$field_name] = array( $field->getFieldType(), $this->{$field_name} );
} else {
$data[$field_name] = array( $field->getFieldType(), $this->
sleep($field_name) );
}
}
return $data;
}
ActiveRecord::getArrayForDb |
( |
| ) |
|
|
final |
static ActiveRecord::getCalledClass |
( |
| ) |
|
|
staticprotected |
static ActiveRecord::getCollection |
( |
| ) |
|
|
static |
ActiveRecord::getConnectorContainerName |
( |
| ) |
|
- Returns
- string Return the Name of your Connector Table
Reimplemented in ilADTActiveRecordWrapper, ilBibliographicSetting, and arMixedKey.
Definition at line 74 of file class.ActiveRecord.php.
References $connector_container_name, getCalledClass(), and returnDbTableName().
Referenced by 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().
{
if ($this->connector_container_name) {
} else {
}
}
static ActiveRecord::getFirstFromLastQuery |
( |
| ) |
|
|
static |
ActiveRecord::getPrimaryFieldValue |
( |
| ) |
|
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.
{
return $srModelObjectList->innerjoin($tablename, $on_this, $on_external, $fields, $operator, $both_external);
}
static ActiveRecord::innerjoinAR |
( |
ActiveRecord |
$ar, |
|
|
|
$on_this, |
|
|
|
$on_external, |
|
|
|
$fields = array( '*' ) , |
|
|
|
$operator = '=' , |
|
|
|
$both_external = false |
|
) |
| |
|
static |
ActiveRecord::installConnector |
( |
| ) |
|
ActiveRecord::installDatabase |
( |
| ) |
|
|
finalprotected |
- Returns
- bool
Definition at line 399 of file class.ActiveRecord.php.
{
$fields = array();
$fields[$field->getName()] = $field->getAttributesForConnector();
}
} else {
}
}
static ActiveRecord::installDB |
( |
| ) |
|
|
staticfinal |
static ActiveRecord::last |
( |
| ) |
|
|
static |
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.
{
return $srModelObjectList->leftjoin($tablename, $on_this, $on_external, $fields, $operator, $both_external);
}
static ActiveRecord::limit |
( |
|
$start, |
|
|
|
$end |
|
) |
| |
|
static |
static ActiveRecord::orderBy |
( |
|
$orderBy, |
|
|
|
$orderDirection = 'ASC' |
|
) |
| |
|
static |
- Parameters
-
| $orderBy | |
string | $orderDirection | |
- Returns
- ActiveRecordList
Definition at line 696 of file class.ActiveRecord.php.
{
$srModelObjectList->orderBy($orderBy, $orderDirection);
return $srModelObjectList;
}
static ActiveRecord::preloadObjects |
( |
| ) |
|
|
static |
static ActiveRecord::raw |
( |
|
$set_raw = true | ) |
|
|
static |
static ActiveRecord::removeDBField |
( |
|
$field_name | ) |
|
|
staticfinal |
static ActiveRecord::renameDBField |
( |
|
$old_name, |
|
|
|
$new_name |
|
) |
| |
|
staticfinal |
static ActiveRecord::resetDB |
( |
| ) |
|
|
staticfinal |
static ActiveRecord::returnDbTableName |
( |
| ) |
|
|
staticabstract |
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().
ActiveRecord::setConnectorContainerName |
( |
|
$connector_container_name | ) |
|
ActiveRecord::setPrimaryFieldValue |
( |
|
$value | ) |
|
ActiveRecord::sleep |
( |
|
$field_name | ) |
|
ActiveRecord::storeObjectToCache |
( |
| ) |
|
static ActiveRecord::tableExists |
( |
| ) |
|
|
staticfinal |
static ActiveRecord::truncateDB |
( |
| ) |
|
|
staticfinal |
static ActiveRecord::updateDB |
( |
| ) |
|
|
staticfinal |
ActiveRecord::wakeUp |
( |
|
$field_name, |
|
|
|
$field_value |
|
) |
| |
static ActiveRecord::where |
( |
|
$where, |
|
|
|
$operator = NULL |
|
) |
| |
|
static |
Field Documentation
ActiveRecord::$ar_safe_read = true |
|
protected |
ActiveRecord::$connector_container_name = '' |
|
protected |
const ActiveRecord::ACTIVE_RECORD_VERSION = '2.0.7' |
The documentation for this class was generated from the following file: