Piwik\DataTable\
Stores an array of DataTables indexed by one type of DataTable metadata (such as site ID or period).
DataTable Maps are returned on all queries that involve multiple sites and/or multiple periods. The Maps will contain a DataTable for each site and period combination.
The Map implements some DataTable such as queueFilter() and getRowsCount.
The class defines the following methods:
getKeyName()
— Returns a string description of the data used to index the DataTables.setKeyName()
— Set the name of they metadata used to index DataTables.getRowsCount()
— Returns the number of DataTables in this DataTable\Map.queueFilter()
— Queue a filter to DataTable child of contained by this instance.applyQueuedFilters()
— Apply the filters previously queued to each DataTable contained by this DataTable\Map.filter()
— Apply a filter to all tables contained by this instance.filterSubtables()
— Apply a filter to all subtables contained by this instance.queueFilterSubtables()
— Apply a queued filter to all subtables contained by this instance.getDataTables()
— Returns the array of DataTables contained by this class.getTable()
— Returns the table with the specific label.hasTable()
getFirstRow()
— Returns the first element in the Map's array.getLastRow()
— Returns the last element in the Map's array.addTable()
— Adds a new DataTable or Map instance to this DataTable\Map.getRowFromIdSubDataTable()
__toString()
— Returns a string output of this DataTable\Map (applying the default renderer to every DataTable of this DataTable\Map).enableRecursiveSort()
— See DataTable::enableRecursiveSort().disableFilter()
— See DataTable::disableFilter().renameColumn()
— Renames the given column in each contained DataTable.deleteColumns()
— Deletes the specified columns in each contained DataTable.deleteRow()
— Deletes a table from the array of DataTables.deleteColumn()
— Deletes the given column in every contained DataTable.getColumn()
— Returns the array containing all column values in all contained DataTables for the requested column.mergeChildren()
— Merges the rows of every child DataTable into a new one and returns it.addDataTable()
— Sums a DataTable to all the tables in this array.mergeSubtables()
— Returns a new DataTable\Map w/ child tables that have had their subtables merged.getEmptyClone()
— Returns a new DataTable\Map w/o any child DataTables, but with the same key name as this instance.getMetadataIntersectArray()
— Returns the intersection of children's metadata arrays (what they all have in common).deleteRowsMetadata()
— Delete row metadata by name in every row.getColumns()
— See DataTable::getColumns().getKeyName()
Returns a string description of the data used to index the DataTables.
This label is used by DataTable Renderers (it becomes a column name or the XML description tag).
string
—
eg, 'idSite'
, 'period'
setKeyName()
Set the name of they metadata used to index DataTables. See getKeyName().
It accepts the following parameter(s):
$name
(string
) —It does not return anything or a mixed result.
getRowsCount()
Returns the number of DataTables in this DataTable\Map.
int
value.queueFilter()
Queue a filter to DataTable child of contained by this instance.
See DataTable::queueFilter() for more information..
$className
(string
|Closure
) —
Filter name, eg. 'Limit'
or a Closure.$parameters
(array
) —
Filter parameters, eg. array(50, 10)
.applyQueuedFilters()
Apply the filters previously queued to each DataTable contained by this DataTable\Map.
filter()
Apply a filter to all tables contained by this instance.
$className
(string
|Closure
) —
Name of filter class or a Closure.$parameters
(array
) —
Parameters to pass to the filter.filterSubtables()
Apply a filter to all subtables contained by this instance.
$className
(string
|Closure
) —
Name of filter class or a Closure.$parameters
(array
) —
Parameters to pass to the filter.queueFilterSubtables()
Apply a queued filter to all subtables contained by this instance.
$className
(string
|Closure
) —
Name of filter class or a Closure.$parameters
(array
) —
Parameters to pass to the filter.getDataTables()
Returns the array of DataTables contained by this class.
DataTable[]
|Map[]
—getTable()
Returns the table with the specific label.
hasTable()
It accepts the following parameter(s):
$label
(string
) —It returns a bool
value.
getFirstRow()
Returns the first element in the Map's array.
getLastRow()
Returns the last element in the Map's array.
addTable()
Adds a new DataTable or Map instance to this DataTable\Map.
It accepts the following parameter(s):
getRowFromIdSubDataTable()
It accepts the following parameter(s):
$idSubtable
It does not return anything or a mixed result.
__toString()
Returns a string output of this DataTable\Map (applying the default renderer to every DataTable of this DataTable\Map).
string
value.enableRecursiveSort()
See DataTable::enableRecursiveSort().
disableFilter()
See DataTable::disableFilter().
It accepts the following parameter(s):
$className
It does not return anything or a mixed result.
renameColumn()
Renames the given column in each contained DataTable.
See DataTable::renameColumn().
It accepts the following parameter(s):
$oldName
(string
) —
$newName
(string
) —
It does not return anything or a mixed result.
deleteColumns()
Deletes the specified columns in each contained DataTable.
See DataTable::deleteColumns().
$columns
(array
) —
The columns to delete.$deleteRecursiveInSubtables
(bool
) —
This param is currently not used.deleteRow()
Deletes a table from the array of DataTables.
$id
(string
) —
The label associated with DataTable.deleteColumn()
Deletes the given column in every contained DataTable.
DataTable::deleteColumn
It accepts the following parameter(s):
$name
(string
) —It does not return anything or a mixed result.
getColumn()
Returns the array containing all column values in all contained DataTables for the requested column.
$name
(string
) —
The column name.array
value.mergeChildren()
Merges the rows of every child DataTable into a new one and returns it. This function will also set the label of the merged rows to the label of the DataTable they were originally from.
The result of this function is determined by the type of DataTable this instance holds. If this DataTable\Map instance holds an array of DataTables, this function will transform it from:
Label 0:
DataTable(row1)
Label 1:
DataTable(row2)
to:
DataTable(row1[label = 'Label 0'], row2[label = 'Label 1'])
If this instance holds an array of DataTable\Maps, this function will transform it from:
Outer Label 0: // the outer DataTable\Map
Inner Label 0: // one of the inner DataTable\Maps
DataTable(row1)
Inner Label 1:
DataTable(row2)
Outer Label 1:
Inner Label 0:
DataTable(row3)
Inner Label 1:
DataTable(row4)
to:
Inner Label 0:
DataTable(row1[label = 'Outer Label 0'], row3[label = 'Outer Label 1'])
Inner Label 1:
DataTable(row2[label = 'Outer Label 0'], row4[label = 'Outer Label 1'])
If this instance holds an array of DataTable\Maps, the metadata of the first child is used as the metadata of the result.
This function can be used, for example, to smoosh IndexedBySite archive query results into one DataTable w/ different rows differentiated by site ID.
Note: This DataTable/Map will be destroyed and will be no longer usable after the tables have been merged into the new dataTable to reduce memory usage. Destroying all DataTables within the Map also seems to fix a Segmentation Fault that occurred in the AllWebsitesDashboard when having > 16k sites.
addDataTable()
Sums a DataTable to all the tables in this array.
Note: Will only add $tableToSum
if the childTable has some rows.
See DataTable::addDataTable().
It accepts the following parameter(s):
$tableToSum
(DataTable
) —It does not return anything or a mixed result.
mergeSubtables()
Returns a new DataTable\Map w/ child tables that have had their subtables merged.
See DataTable::mergeSubtables().
Map
value.getEmptyClone()
Returns a new DataTable\Map w/o any child DataTables, but with the same key name as this instance.
Map
value.getMetadataIntersectArray()
Returns the intersection of children's metadata arrays (what they all have in common).
$name
(string
) —
The metadata name.mixed
value.deleteRowsMetadata()
Delete row metadata by name in every row.
It accepts the following parameter(s):
$name
$deleteRecursiveInSubtables
(bool
) —
It does not return anything or a mixed result.
getColumns()
See DataTable::getColumns().
array
value.