Documentation

DataRow extends DataRow

Представление строки в таблице в хранилище

Tags
author

Vahan P. Grigoryan

Table of Contents

Constants

JsonSchema  = ['type' => 'object', 'patternProperties' => ['.*' => ['type' => ['number', 'string', 'boolean', 'object', 'array', 'null']]]]
Data validation schema.

Properties

$changed  : bool
$datecreated  : DateTimeField
$datemodified  : DateTimeField
$id  : int
$id  : int
$properties  : array<string|int, mixed>
$table  : DataTable
$_changed  : bool|null
Object change indicator.
$_changeKeyCase  : bool|null
Change case on object keys
$_data  : mixed
Object data, properties.
$_original  : mixed
Contains data received during initialization.
$_prefix  : string|null
Prefix for properties, to ensure proper operation with storages.
$_storage  : Storage
Хранилище
$_table  : DataTable
Data Table object
$_validationResult  : ValidationResult
Validation results
$casts  : array<string|int, mixed>

Methods

__construct()  : mixed
Конструктор
__destruct()  : mixed
Destructor
__get()  : mixed
Retrieves the value of a dynamic or inaccessible property from the object.
__isset()  : bool
Checks whether a property is set in the object.
__set()  : void
Sets the value of a dynamic or inaccessible property within the object.
__toString()  : string
__unset()  : void
Unsets a property in the object.
Clear()  : mixed
Cleans object
CopyToObject()  : ExtendedObject
Copies data from the current object to an ExtendedObject.
Count()  : int
Counts the number of elements in the object.
Delete()  : QueryInfo
DispatchEvent()  : object|null
Dispatches an event.
Fill()  : void
Заполняет строку из обьекта
GetData()  : mixed
Retrieves the current data of the object.
getIterator()  : ExtendedObjectIterator
Returns an iterator for iterating over the data of the ExtendedObject.
GetValidationData()  : mixed
HandleEvent()  : self
Adds an event handler.
IsChanged()  : bool
Checks if the object has been changed.
IsPropertyChanged()  : bool
Поле изменено
jsonSerialize()  : array<string|int, mixed>
Serializes the object to a value that can be serialized by json_encode.
JsonUnserialize()  : static
Constructs a new object instance from a JSON-encoded string.
offsetExists()  : bool
Checks if a value exists at the specified offset.
offsetGet()  : mixed|null
Retrieves the value at the specified offset.
offsetSet()  : void
Sets the value at the specified offset.
offsetUnset()  : void
Unsets the value at the specified offset.
Original()  : object
Returns the original data provided during object initialization.
Prefix()  : string
Retrieves the prefix used for object properties.
RemoveHandler()  : self
Removes an event handler.
Save()  : QueryInfo|bool
Вызывает SaveRow у таблицы
Schema()  : object|string
SetData()  : void
Sets data for the object.
Storage()  : Storage
Возвращает хранилище
ToArray()  : array<string|int, mixed>
Возвращает строку в виде массива
ToJSON()  : string
Converts the object's data to a JSON string.
ToString()  : string
Конвертирует в строку
Type()  : string
Retrieves the type of a specific property.
UpdateOriginal()  : void
Updates the original data with the current data of the object.
Validate()  : bool
Validates the object's data against a JSON schema.
_processDefaultValues()  : bool
_typeExchange()  : mixed
Конвертация типов
_typeToData()  : mixed
Конвертирует данные для передачи через функцию GetData

Constants

JsonSchema

Data validation schema.

public mixed JsonSchema = ['type' => 'object', 'patternProperties' => ['.*' => ['type' => ['number', 'string', 'boolean', 'object', 'array', 'null']]]]

Properties

$properties

public array<string|int, mixed> $properties

$_changed

Object change indicator.

protected bool|null $_changed = false

$_changeKeyCase

Change case on object keys

protected bool|null $_changeKeyCase = true

$_original

Contains data received during initialization.

protected mixed $_original

$_prefix

Prefix for properties, to ensure proper operation with storages.

protected string|null $_prefix = ""

$_validationResult

Validation results

protected ValidationResult $_validationResult

$casts

protected static array<string|int, mixed> $casts = []

Methods

__get()

Retrieves the value of a dynamic or inaccessible property from the object.

public __get(string $property) : mixed

This magic method is invoked when attempting to access a property that is not accessible or does not exist within the object's scope using the arrow operator (->).

Parameters
$property : string

The name of the property to retrieve.

Return values
mixed

The value of the specified property.

__isset()

Checks whether a property is set in the object.

public __isset(string $property) : bool

This magic method is triggered when attempting to check whether a property is set in the object using isset().

Parameters
$property : string

The name of the property being checked.

Return values
bool

Returns true if the property is set, false otherwise.

__set()

Sets the value of a dynamic or inaccessible property within the object.

public __set(string $property, mixed $value) : void

This magic method is invoked when attempting to assign a value to a property that is not accessible or does not exist within the object's scope using the arrow operator (->).

Parameters
$property : string

The name of the property to set.

$value : mixed

The value to assign to the property.

__toString()

public __toString() : string
Return values
string

__unset()

Unsets a property in the object.

public __unset(string $property) : void

This magic method is triggered when attempting to unset a property in the object using unset().

Parameters
$property : string

The name of the property to unset.

CopyToObject()

Copies data from the current object to an ExtendedObject.

public CopyToObject() : ExtendedObject

This method copies relevant data from the current instance to a new instance of the ExtendedObject class. It allows you to create a similar object with additional functionality provided by ExtendedObject.

Return values
ExtendedObject

A new instance of ExtendedObject with copied data.

Count()

Counts the number of elements in the object.

public Count() : int

This method returns the number of elements in the object.

Return values
int

The number of elements in the object.

DispatchEvent()

Dispatches an event.

public DispatchEvent(string|Event $event[, mixed $args = null ][, bool $async = false ]) : object|null
Parameters
$event : string|Event

The event object or its name.

$args : mixed = null

Additional arguments to pass to the event handlers.

$async : bool = false

Whether to dispatch the event asynchronously.

Return values
object|null

The event object with updated arguments, or null if the event does not exist.

Fill()

Заполняет строку из обьекта

public Fill(mixed $obj) : void
Parameters
$obj : mixed

обьект или массив

GetData()

Retrieves the current data of the object.

public GetData([bool $type = true ]) : mixed

This method returns the current data of the object. If the $type parameter is set to true, the data is converted according to the object's type conversion rules; otherwise, the raw data is returned without conversion.

Parameters
$type : bool = true

Optional. Determines whether to convert the data according to type conversion rules. Defaults to true.

Return values
mixed

The current data of the object.

getIterator()

Returns an iterator for iterating over the data of the ExtendedObject.

public getIterator() : ExtendedObjectIterator

This method returns an iterator that allows iterating over the data of the ExtendedObject. It enables the use of foreach loops and other iterable operations on ExtendedObject instances.

Return values
ExtendedObjectIterator

An iterator for the data of the ExtendedObject.

GetValidationData()

public GetValidationData() : mixed

HandleEvent()

Adds an event handler.

public HandleEvent(array<string|int, mixed>|string $ename, mixed $listener) : self
Parameters
$ename : array<string|int, mixed>|string

The event name or an array of event names.

$listener : mixed

The event handler.

Return values
self

IsChanged()

Checks if the object has been changed.

public IsChanged() : bool

This method determines whether any changes have been made to the object's data since its initialization or the last update. It returns true if changes have been made, indicating that the object state is different from its original state; otherwise, it returns false.

Return values
bool

True if the object has been changed; otherwise, false.

IsPropertyChanged()

Поле изменено

public IsPropertyChanged(string $property[, bool $convertData = false ]) : bool
Parameters
$property : string

The name of the property to check for changes.

$convertData : bool = false

(optional) Whether to convert data before comparison. Default is false.

Return values
bool

jsonSerialize()

Serializes the object to a value that can be serialized by json_encode.

public jsonSerialize() : array<string|int, mixed>

This method is called during JSON serialization of the object. It allows the object to be serialized to a JSON-serializable representation using the json_encode function.

Return values
array<string|int, mixed>

The serializable representation of the object.

JsonUnserialize()

Constructs a new object instance from a JSON-encoded string.

public static JsonUnserialize(string $json) : static

This method creates a new instance of the class from a JSON-encoded string. It accepts a JSON string representing the object and returns a new instance of the class.

Parameters
$json : string

The JSON-encoded string representing the object.

Return values
static

The new instance of the class.

offsetExists()

Checks if a value exists at the specified offset.

public offsetExists(string|int $offset) : bool

This method checks if a value exists at the specified offset in the ExtendedObject. It allows checking the existence of values using array access syntax, e.g., isset($object['key']).

Parameters
$offset : string|int

The offset to check.

Tags
throws
InvalidArgumentException

If the offset is not a string or an integer.

Return values
bool

True if a value exists at the specified offset, false otherwise.

offsetGet()

Retrieves the value at the specified offset.

public offsetGet(string|int $offset) : mixed|null

This method retrieves the value at the specified offset in the ExtendedObject. It allows accessing values using array access syntax, e.g., $value = $object['key'].

Parameters
$offset : string|int

The offset of the value to retrieve.

Tags
throws
InvalidArgumentException

If the offset is not a string or an integer.

Return values
mixed|null

The value at the specified offset, or null if the offset does not exist.

offsetSet()

Sets the value at the specified offset.

public offsetSet(string|int $offset, mixed $value) : void

This method sets the value at the specified offset in the ExtendedObject. It allows setting values using array access syntax, e.g., $object['key'] = $value.

Parameters
$offset : string|int

The offset at which to set the value.

$value : mixed

The value to set at the specified offset.

Tags
throws
InvalidArgumentException

If the offset is not a string or an integer.

offsetUnset()

Unsets the value at the specified offset.

public offsetUnset(string|int $offset) : void

This method unsets the value at the specified offset in the ExtendedObject. It allows unsetting values using array access syntax, e.g., unset($object['key']).

Parameters
$offset : string|int

The offset of the value to unset.

Tags
throws
InvalidArgumentException

If the offset is not a string or an integer.

Original()

Returns the original data provided during object initialization.

public Original() : object

This method returns the original data provided during object initialization as an object. The original data represents the state of the object before any changes.

Return values
object

An object containing the original data provided during initialization.

Prefix()

Retrieves the prefix used for object properties.

public Prefix() : string

This method returns the prefix used for object properties. The prefix is typically set during object initialization and is useful for distinguishing properties when working with storage systems.

Return values
string

The prefix used for object properties.

RemoveHandler()

Removes an event handler.

public RemoveHandler(string $ename, mixed $listener) : self
Parameters
$ename : string

The event name.

$listener : mixed

The event handler to remove.

Return values
self

Save()

Вызывает SaveRow у таблицы

public Save([bool $performValidationBeforeSave = false ]) : QueryInfo|bool
Parameters
$performValidationBeforeSave : bool = false
Return values
QueryInfo|bool

Schema()

public static Schema([bool $exportAsString = false ][, mixed $addElements = [] ]) : object|string
Parameters
$exportAsString : bool = false
$addElements : mixed = []
Return values
object|string

SetData()

Sets data for the object.

public SetData(mixed $data) : void

This method allows setting data for the object. It can accept various types of data, such as arrays, objects, or ExtendedObject instances.

Parameters
$data : mixed

The data to set for the object.

ToArray()

Возвращает строку в виде массива

public ToArray([bool $noPrefix = false ][, Closure|null $callback = null ]) : array<string|int, mixed>
Parameters
$noPrefix : bool = false

да - возвращать без префиксами

$callback : Closure|null = null
Return values
array<string|int, mixed>

ToJSON()

Converts the object's data to a JSON string.

public ToJSON() : string

This method serializes the object's data into a JSON string representation.

Return values
string

The JSON string representing the object's data.

ToString()

Конвертирует в строку

public ToString() : string
Return values
string

Type()

Retrieves the type of a specific property.

public Type(string $property) : string

This method returns the data type associated with the given property name. It allows you to determine the expected type of a property within the class.

Parameters
$property : string

The name of the property.

Return values
string

The data type (e.g., 'string', 'int', 'bool', etc.) of the property.

UpdateOriginal()

Updates the original data with the current data of the object.

public UpdateOriginal() : void

This method updates the original data of the object with its current data. It is typically used after modifying the object's data to synchronize the original and current states.

Validate()

Validates the object's data against a JSON schema.

public Validate([bool $throwExceptions = false ]) : bool

This method validates the object's data against a predefined JSON schema. If the validation fails, it returns false. Optionally, you can set $throwExceptions to true to throw a ValidationException upon failure.

Parameters
$throwExceptions : bool = false

Whether to throw a ValidationException upon failure.

Tags
throws
ValidationException

If $throwExceptions is true and the validation fails.

Return values
bool

True if the object's data is valid according to the schema, false otherwise.

_processDefaultValues()

protected _processDefaultValues() : bool
Return values
bool

_typeExchange()

Конвертация типов

protected _typeExchange(string $mode, string $property[, mixed $value = false ]) : mixed
Parameters
$mode : string

режим, get или сет

$property : string

свойство

$value : mixed = false

значение

Return values
mixed

результат

_typeToData()

Конвертирует данные для передачи через функцию GetData

protected _typeToData(mixed $data) : mixed
Parameters
$data : mixed

данные для конвертации

Return values
mixed

сконвертированные данные


        
On this page

Search results