DataSourceBase
in package
Base class for the Table widget data sources.
Table of Contents
- $keyColumn : string
- $offset : int
- construct() : mixed
- Class constructor.
- getCount() : int
- Returns a total number of records in the data source.
- getRecords() : array<string|int, mixed>
- Return records from the data source.
- initRecords() : mixed
- Initializes records in the data source.
- purge() : mixed
- Removes all records from the data source.
- readRecords() : array<string|int, mixed>
- Returns a set of records from the data source.
- reset() : mixed
- Rewinds the the data source to the first record.
- searchRecords() : mixed
- Identical to getRecords except provided with a search query.
Properties
$keyColumn
protected
string
$keyColumn
Specifies a name of record's key column
$offset
protected
int
$offset
= 0
Internal record offset
Methods
construct()
Class constructor.
public
construct([string $keyColumn = 'id' ]) : mixed
Parameters
- $keyColumn : string = 'id'
-
Specifies a name of the key column.
Return values
mixed —getCount()
Returns a total number of records in the data source.
public
abstract getCount() : int
Return values
int —getRecords()
Return records from the data source.
public
abstract getRecords(int $offset, int $count) : array<string|int, mixed>
Parameters
- $offset : int
-
Specifies the offset of the first record to return, zero-based.
- $count : int
-
Specifies the number of records to return.
Return values
array<string|int, mixed> —Returns the records. If there are no more records, returns an empty array.
initRecords()
Initializes records in the data source.
public
abstract initRecords(array<string|int, mixed> $records) : mixed
The method doesn't replace existing records and could be called multiple times in order to fill the data source.
Parameters
- $records : array<string|int, mixed>
-
Records to initialize in the data source.
Return values
mixed —purge()
Removes all records from the data source.
public
abstract purge() : mixed
Return values
mixed —readRecords()
Returns a set of records from the data source.
public
readRecords([int $count = 10 ]) : array<string|int, mixed>
Parameters
- $count : int = 10
-
Specifies the number of records to return.
Return values
array<string|int, mixed> —Returns the records. If there are no more records, returns an empty array.
reset()
Rewinds the the data source to the first record.
public
reset() : mixed
Use this method with the readRecords() method.
Return values
mixed —searchRecords()
Identical to getRecords except provided with a search query.
public
searchRecords(mixed $query, mixed $offset, mixed $count) : mixed
Parameters
- $query : mixed
- $offset : mixed
- $count : mixed