Documentation

DataTable extends DataTable

Таблица, представление данных в хранилище

Tags
author

Vahan P. Grigoryan

Table of Contents

Properties

$_cache  : ArrayList
List of loaded rows
$_point  : DataAccessPoint
Data access point
$_reader  : IDataReader
DataReader
$_returnAs  : string
Rows class name
$_returnAsExtended  : string
$_storage  : Storage
Хранилише
$fullSelection  : mixed

Methods

__construct()  : void
Конструктор
Affected()  : int|null
Gets the number of affected rows by the last database operation.
CacheAll()  : mixed
Caches all data from the data source.
Clear()  : void
Clears the data table, removing all elements.
Count()  : int
Gets the number of rows in the DataTable.
Create()  : DataTable
Static constructor
CreateEmptyRow()  : mixed
Creates an empty row object with optional initial data.
DeleteAllRows()  : void
Deletes all rows from the data source.
DeleteRow()  : QueryInfo
Deletes a DataRow from the data source.
ExportCSV()  : void
Экспорт в csv
ExportJson()  : void
Выгрузить в XML
ExportXML()  : void
Выгрузить в XML
Fields()  : array<string|int, mixed>
Retrieves the field names of the DataTable.
First()  : mixed
Retrieves the first item from the data table.
getIterator()  : DataTableIterator
Возвращает итератор
HasRows()  : bool
Checks if the DataTable has any rows.
ImportCSV()  : void
Импортировать из CSV
ImportXML()  : void
Импортировать из XML
Item()  : mixed
Retrieves an item from the data source at the specified index.
Load()  : self
Executes a query to load data into the DataTable.
LoadByQuery()  : static|null
offsetExists()  : bool
Checks if data exists at the specified index.
offsetGet()  : DataRow
Retrieves the value at the specified index.
offsetSet()  : void
Sets a value by index.
offsetUnset()  : void
Removes data at the specified index.
Point()  : DataAccessPoint|null
Retrieves the data access point associated with the DataTable.
SaveAllRows()  : void
Saves all DataRow objects in the data table to the data source.
SaveRow()  : QueryInfo|bool
Сохраняет переданную строку в базу данных
Set()  : void
Sets an data at the specified index in the data table cache.
SetFullSelect()  : mixed
Storage()  : Storage
Возвращает обьект хранилище
ToArray()  : array<string|int, mixed>
Converts the data table to an array.
Unpluck()  : array<string|int, mixed>
Unplucks a selected fields from table and returns array containing unplucked rows
_createDataRowObject()  : mixed
Создает обьект данных представления строки
_loadByFilter()  : static|null
_loadFromFileXML()  : bool
_read()  : mixed
Reads data from a data source.
_readTo()  : mixed
Reads data from a data source up to a specified index.
_replaceFields()  : string
DeleteByFilter()  : bool
RestoreByFilter()  : bool
UpdateByFilter()  : bool
_getTableEncoding()  : object
Retrieves the encoding information for a specified table.

Properties

$_returnAs

Rows class name

protected string $_returnAs = null

$_returnAsExtended

protected string $_returnAsExtended

$fullSelection

protected static mixed $fullSelection = false

Methods

__construct()

Конструктор

public __construct(DataAccessPoint $point[, IDataReader|null $reader = null ][, string|Closure $returnAs = 'Colibri\Data\Storages\Models\DataRow' ][, Storage|null $storage = null ]) : void
Parameters
$point : DataAccessPoint

точка доступа

$reader : IDataReader|null = null

ридер

$returnAs : string|Closure = 'Colibri\Data\Storages\Models\DataRow'

возвращать в виде класса

$storage : Storage|null = null

хранилище

Affected()

Gets the number of affected rows by the last database operation.

public Affected() : int|null
Return values
int|null

The number of affected rows, or null if not available.

CacheAll()

Caches all data from the data source.

public CacheAll([bool $closeReader = true ]) : mixed
Parameters
$closeReader : bool = true

(optional) Whether to close the reader after caching. Default is true.

Return values
mixed

The cached data, or null if caching fails.

Clear()

Clears the data table, removing all elements.

public Clear() : void

Count()

Gets the number of rows in the DataTable.

public Count() : int
Return values
int

The number of rows in the DataTable.

CreateEmptyRow()

Creates an empty row object with optional initial data.

public CreateEmptyRow([object|array<string|int, mixed> $data = [] ]) : mixed
Parameters
$data : object|array<string|int, mixed> = []

(optional) Initial data to populate the row object. Default is an empty array.

Return values
mixed

The created empty row object, or null if creation fails.

DeleteAllRows()

Deletes all rows from the data source.

public DeleteAllRows() : void

DeleteRow()

Deletes a DataRow from the data source.

public DeleteRow(DataRow $row) : QueryInfo
Parameters
$row : DataRow

The DataRow object to be deleted.

Return values
QueryInfo

A QueryInfo object containing information about the executed delete query.

ExportCSV()

Экспорт в csv

public ExportCSV(string $file) : void
Parameters
$file : string

файл, куда выгружать

ExportJson()

Выгрузить в XML

public ExportJson(string $file) : void
Parameters
$file : string

файл, куда выгружать

ExportXML()

Выгрузить в XML

public ExportXML(string $file) : void
Parameters
$file : string

файл, куда выгружать

Fields()

Retrieves the field names of the DataTable.

public Fields() : array<string|int, mixed>
Return values
array<string|int, mixed>

An array containing the field names of the DataTable.

First()

Retrieves the first item from the data table.

public First() : mixed
Return values
mixed

The first item from the data table, or null if the collection is empty.

HasRows()

Checks if the DataTable has any rows.

public HasRows() : bool
Return values
bool

True if the DataTable has rows, false otherwise.

ImportCSV()

Импортировать из CSV

public ImportCSV(string $file[, int $firstrow = 1 ][, Logger|null $logger = null ]) : void
Parameters
$file : string

файл источник

$firstrow : int = 1

номер строки, с которой начинаются данные

$logger : Logger|null = null

ImportXML()

Импортировать из XML

public ImportXML(string $file[, int $firstrow = 1 ][, Logger|null $logger = null ]) : void
Parameters
$file : string

файл источник

$firstrow : int = 1

номер строки, с которой начинаются данные

$logger : Logger|null = null

Item()

Retrieves an item from the data source at the specified index.

public Item(int $index) : mixed
Parameters
$index : int

The index of the item to retrieve.

Return values
mixed

The item at the specified index, or null if the index is out of range.

Load()

Executes a query to load data into the DataTable.

public Load(string $query[, array<string|int, mixed> $params = [] ]) : self
Parameters
$query : string

The SQL query to execute.

$params : array<string|int, mixed> = []

(optional) An associative array of parameters to bind to the query. Default is an empty array.

Return values
self

LoadByQuery()

public static LoadByQuery(Storage|string $storage, string $query, array<string|int, mixed> $params) : static|null
Parameters
$storage : Storage|string
$query : string
$params : array<string|int, mixed>
Return values
static|null

offsetExists()

Checks if data exists at the specified index.

public offsetExists(int $offset) : bool
Parameters
$offset : int

The index to check for data.

Return values
bool

True if data exists at the index, false otherwise.

offsetGet()

Retrieves the value at the specified index.

public offsetGet(int $offset) : DataRow
Parameters
$offset : int

The index of the value to retrieve.

Return values
DataRow

The value at the specified index.

offsetSet()

Sets a value by index.

public offsetSet(int $offset, DataRow $value) : void
Parameters
$offset : int

The index to set the value.

$value : DataRow

The value to set.

offsetUnset()

Removes data at the specified index.

public offsetUnset(int $offset) : void
Parameters
$offset : int

The index of the data to remove.

Point()

Retrieves the data access point associated with the DataTable.

public Point() : DataAccessPoint|null
Return values
DataAccessPoint|null

The data access point associated with the DataTable, or null if not set.

SaveAllRows()

Saves all DataRow objects in the data table to the data source.

public SaveAllRows() : void

SaveRow()

Сохраняет переданную строку в базу данных

public SaveRow(DataRow|DataRow $row[, string|null $idField = null ][, bool|null $convert = true ]) : QueryInfo|bool
Parameters
$row : DataRow|DataRow

строка для сохранения

$idField : string|null = null

поле для автоинкремента, если не найдется в таблице

$convert : bool|null = true

(optional) Whether to convert data before saving. Default is true.

Tags
throws
DataModelException
Return values
QueryInfo|bool

Set()

Sets an data at the specified index in the data table cache.

public Set(int $index, ExtendedObject $data) : void
Parameters
$index : int

The index at which to set the data.

$data : ExtendedObject

The data to set.

SetFullSelect()

public static SetFullSelect(bool $value) : mixed
Parameters
$value : bool

ToArray()

Converts the data table to an array.

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

(optional) Whether to exclude the prefix from keys. Default is false.

Return values
array<string|int, mixed>

An array representation of the collection.

Unpluck()

Unplucks a selected fields from table and returns array containing unplucked rows

public Unpluck(array<string|int, mixed> $fields) : array<string|int, mixed>
Parameters
$fields : array<string|int, mixed>

fields to unpluck from row

Return values
array<string|int, mixed>

An array representation of the collection.

_createDataRowObject()

Создает обьект данных представления строки

protected _createDataRowObject(ExtendedObject $result) : mixed
Parameters
$result : ExtendedObject

_loadByFilter()

protected static _loadByFilter(Storage $storage[, int $page = -1 ][, int $pagesize = 20 ][, string $filter = null ][, string $order = null ][, array<string|int, mixed> $params = [] ][, bool $calculateAffected = true ]) : static|null
Parameters
$storage : Storage
$page : int = -1
$pagesize : int = 20
$filter : string = null
$order : string = null
$params : array<string|int, mixed> = []
$calculateAffected : bool = true
Return values
static|null

_loadFromFileXML()

protected static _loadFromFileXML(Storage|string $storage, string|File $file, string $tag, array<string|int, mixed> $fieldsMap[, array<string|int, mixed> $additionalFields = [] ]) : bool
Parameters
$storage : Storage|string
$file : string|File
$tag : string
$fieldsMap : array<string|int, mixed>
$additionalFields : array<string|int, mixed> = []
Return values
bool

_read()

Reads data from a data source.

protected _read() : mixed
Return values
mixed

The data read from the data source, or null if reading fails.

_readTo()

Reads data from a data source up to a specified index.

protected _readTo(int $index) : mixed
Parameters
$index : int

The index up to which data should be read.

Return values
mixed

The data read from the data source up to the specified index, or null if reading fails.

_replaceFields()

protected static _replaceFields(string $value, Storage $storage) : string
Parameters
$value : string
$storage : Storage
Return values
string

DeleteByFilter()

protected static DeleteByFilter(Storage|string $storage, string $filter) : bool
Parameters
$storage : Storage|string
$filter : string
Return values
bool

RestoreByFilter()

protected static RestoreByFilter(Storage|string $storage, string $filter) : bool
Parameters
$storage : Storage|string
$filter : string
Return values
bool

UpdateByFilter()

protected static UpdateByFilter(Storage|string $storage, string $filter, array<string|int, mixed> $fields) : bool
Parameters
$storage : Storage|string
$filter : string
$fields : array<string|int, mixed>
Return values
bool

_getTableEncoding()

Retrieves the encoding information for a specified table.

private _getTableEncoding(string $table) : object
Parameters
$table : string

The name of the table to retrieve encoding information for.

Return values
object

An object containing encoding information for the specified table.


        
On this page

Search results