DataFrameModifiers
- Full name:
\MammothPHP\WoollyM\DataFrameModifiers - Parent class:
\MammothPHP\WoollyM\DataFrameStatements - This class is an Abstract class
Methods
extract
Return a Copy object, methods will return new DataFrame objects.
public extract(\MammothPHP\WoollyM\DataFrame $to = new DataFrame()): \MammothPHP\WoollyM\ExtractParameters:
| Parameter | Type | Description |
|---|---|---|
$to | \MammothPHP\WoollyM\DataFrame |
delete
Return a Copy object, methods will return new DataFrame objects.
public delete(): \MammothPHP\WoollyM\Statements\Delete\Deleteinsert
Return an Update statement, methods will return the same DataFrame object
public insert(): \MammothPHP\WoollyM\Statements\Insert\Insertupdate
Return an Update statement, methods will return the same DataFrame object
public update(): \MammothPHP\WoollyM\Statements\Update\UpdatesortColumns
Sort column order using a closure. Then retrieve records will respect the new order.
public sortColumns(mixed $callback = null): staticParameters:
| Parameter | Type | Description |
|---|---|---|
$callback | mixed | - If null, sort will be alphabetic. For closure, example fn(string $a, string $b): int => $a <=> $b; |
sortRecordsByColumns
Sort the records by columns
public sortRecordsByColumns(array|string $by, bool $ascending = true): staticParameters:
| Parameter | Type | Description |
|---|---|---|
$by | array|string | |
$ascending | bool |
Inherited methods
insert
public insert(): \MammothPHP\WoollyM\Statements\Insert\Insert- This method is abstract.
__construct
public __construct(array<int,array> $data = [], mixed $dataDriver = null): mixedParameters:
| Parameter | Type | Description |
|---|---|---|
$data | array<int,array> | Array data to ingest |
$dataDriver | mixed | - Class of custom driver to use. if null, the PhpArray (in-memory) driver will used. |
Throws:
__clone
public __clone(): mixedaddColumn
Adds a new column to the DataFrame. If column already exist, then nothing will happen.
public addColumn(string $columnName): staticParameters:
| Parameter | Type | Description |
|---|---|---|
$columnName | string |
addColumns
Adds multiple columns to the DataFrame.
public addColumns(string[] $columnNames): staticParameters:
| Parameter | Type | Description |
|---|---|---|
$columnNames | string[] |
removeColumn
Removes a column (and all associated data) from the DataFrame.
public removeColumn(string $columnName): staticParameters:
| Parameter | Type | Description |
|---|---|---|
$columnName | string |
hasColumn
Returns a boolean of whether the specified column exists.
public hasColumn(\MammothPHP\WoollyM\Statements\Select\ColumnRepresentation|string $column): boolParameters:
| Parameter | Type | Description |
|---|---|---|
$column | \MammothPHP\WoollyM\Statements\Select\ColumnRepresentation|string |
countColumns
Count unique columns already known
public countColumns(): intcolumns
Return ColumnRepresentation Object extending Select object
public columns(): array<int,\MammothPHP\WoollyM\Statements\Select\ColumnRepresentation>columnsNames
Get unique columns already known
public columnsNames(): array<int,string>mustHaveColumn
Assertion that the DataFrame must have the column specified. If not then an exception is thrown.
public mustHaveColumn(string $columnName): staticParameters:
| Parameter | Type | Description |
|---|---|---|
$columnName | string |
Throws:
getColumnKey
protected getColumnKey(string $columnName): intParameters:
| Parameter | Type | Description |
|---|---|---|
$columnName | string |
createColumnRepresentation
protected createColumnRepresentation(\MammothPHP\WoollyM\ColumnIndex $columnIndex): voidParameters:
| Parameter | Type | Description |
|---|---|---|
$columnIndex | \MammothPHP\WoollyM\ColumnIndex |
addRecord
Add a record, providing an array indexed by column => value
public addRecord(array<string,mixed> $recordArray): staticParameters:
| Parameter | Type | Description |
|---|---|---|
$recordArray | array<string,mixed> |
updateRecord
Update a record by record key. If key does not exist, record will be created.
public updateRecord(int $key, array $recordArray): staticParameters:
| Parameter | Type | Description |
|---|---|---|
$key | int | |
$recordArray | array |
updateCell
public updateCell(int $recordKey, string $column, mixed $newValue): staticParameters:
| Parameter | Type | Description |
|---|---|---|
$recordKey | int | |
$column | string | |
$newValue | mixed |
removeRecord
Remove a record by key
public removeRecord(int $key): staticParameters:
| Parameter | Type | Description |
|---|---|---|
$key | int |
Throws:
getRecord
Get a record by key
public getRecord(int $key): array<string,array>Parameters:
| Parameter | Type | Description |
|---|---|---|
$key | int |
getRecordAsArray
Get a record by key and return an array
public getRecordAsArray(int $key): array<string,array>Parameters:
| Parameter | Type | Description |
|---|---|---|
$key | int |
recordKeyExist
Check if a record key exist
public recordKeyExist(int $recordKey): boolParameters:
| Parameter | Type | Description |
|---|---|---|
$recordKey | int |
convertRecordToAbstract
protected convertRecordToAbstract(array $recordArray): arrayParameters:
| Parameter | Type | Description |
|---|---|---|
$recordArray | array |
convertAbstractToRecordObject
protected convertAbstractToRecordObject(array $abstractRecord): \MammothPHP\WoollyM\RecordParameters:
| Parameter | Type | Description |
|---|---|---|
$abstractRecord | array |
toArray
Outputs a DataFrame as a two-dimensional associative array.
public toArray(bool $fillInNonExistentCol = false): arrayParameters:
| Parameter | Type | Description |
|---|---|---|
$fillInNonExistentCol | bool |
initDriverIterator
protected initDriverIterator(): voidgetRecordsAsArrayIterator
public getRecordsAsArrayIterator(bool $fillAllColumn = false): \IteratorParameters:
| Parameter | Type | Description |
|---|---|---|
$fillAllColumn | bool |
select
Return a Select object
public select(string[] $selections): \MammothPHP\WoollyM\Statements\Select\SelectParameters:
| Parameter | Type | Description |
|---|---|---|
$selections | string[] | column(s) name(s) to select |
selectAll
Return a fixed selectAll object
public selectAll(): \MammothPHP\WoollyM\Statements\Select\SelectAllcol
Return a ColumnRepresentation object, extending Select object.
public col(string $columnName): \MammothPHP\WoollyM\Statements\Select\ColumnRepresentationParameters:
| Parameter | Type | Description |
|---|---|---|
$columnName | string |
Throws:
column
Alias for col() method.
public column(string $columnName): \MammothPHP\WoollyM\Statements\Select\ColumnRepresentationParameters:
| Parameter | Type | Description |
|---|---|---|
$columnName | string |
Automatically generated on 2024-07-03