PHP 클래스 Piwik\DataTable\Row

DataTable rows contain columns, metadata and a subtable ID. Columns and metadata are stored as an array of name => value mappings.
상속: implements ArrayAccess, implements IteratorAggregate
파일 보기 프로젝트 열기: piwik/piwik 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$maxVisitsSummed @see sumRow - implementation detail
$subtableId

공개 메소드들

메소드 설명
__construct ( array $row = [] ) Constructor.
__destruct ( ) When destroyed, a row destroys its associated subtable if there is one.
__toString ( ) : string Applies a basic rendering to the Row and returns the output.
addColumn ( string $name, mixed $value ) Add a new column to the row. If the column already exists, throws an exception.
addColumns ( array $columns ) : void Add many columns to this row.
addMetadata ( string $name, mixed $value ) Add a new metadata to the row. If the metadata already exists, throws an exception.
compareElements ( mixed $elem1, mixed $elem2 ) : boolean Helper function to compare array elements
deleteColumn ( string $name ) : boolean Deletes the given column.
deleteMetadata ( boolean | string $name = false ) : boolean Deletes one metadata value or all metadata values.
export ( ) : array Used when archiving to serialize the Row's properties.
getColumn ( string $name ) : mixed | false Returns a column by name.
getColumns ( ) : array Returns the array containing all the columns.
getIdSubDataTable ( ) : integer | null Returns the ID of the subDataTable.
getMetadata ( string | null $name = null ) : mixed Returns the array of all metadata, or one requested metadata value.
getSubtable ( ) : DataTable | boolean Returns the associated subtable, if one exists. Returns false if none exists.
hasColumn ( string $name ) : boolean Returns true if a column having the given name is already registered. The value will not be evaluated, it will just check whether a column exists independent of its value.
isEqual ( Row $row1, Row $row2 ) : boolean Helper function that tests if two rows are equal.
isSubtableLoaded ( ) : boolean Returns true if the subtable is currently loaded in memory via {@link Piwik\DataTable\Manager}.
isSummaryRow ( ) : boolean Returns true if this row is the summary row, false if otherwise. This function depends on the label of the row, and so, is not 100% accurate.
removeSubtable ( ) Removes the subtable reference.
renameColumn ( string $oldName, string $newName ) Renames a column.
setColumn ( string $name, mixed $value ) Set the value $value to the column called $name.
setColumns ( array $columns ) Set all the columns at once. Overwrites **all** previously set columns.
setMetadata ( string $name, mixed $value ) Set the value $value to the metadata called $name.
setNonLoadedSubtableId ( integer $subtableId )
setSubtable ( DataTable $subTable ) : DataTable Attaches a subtable to this row, overwriting the existing subtable, if any.
sumRow ( Row $rowToSum, boolean $enableCopyMetadata = true, array | boolean $aggregationOperations = false ) Sums the given $rowToSum columns values to the existing row column values.
sumRowMetadata ( Row $rowToSum, array $aggregationOperations = [] ) Sums the metadata in $rowToSum with the metadata in $this row.
sumSubtable ( DataTable $subTable ) Sums a DataTable to this row's subtable. If this row has no subtable a new one is created.

보호된 메소드들

메소드 설명
sumRowArray ( number | boolean $thisColumnValue, number | array $columnToSumValue ) : array | integer Helper function: sums 2 values
warnWhenSummingTwoStrings ( $thisColumnValue, $columnToSumValue )

비공개 메소드들

메소드 설명
getColumnValuesMerged ( $operation, $thisColumnValue, $columnToSumValue, $thisRow, $rowToSum )
isSummableColumn ( $columnName )
warnIfSubtableAlreadyExists ( )

메소드 상세

__construct() 공개 메소드

Constructor.
public __construct ( array $row = [] )
$row array An array with the following structure: array( Row::COLUMNS => array('label' => 'Piwik', 'column1' => 42, 'visits' => 657, 'time_spent' => 155744), Row::METADATA => array('logo' => 'test.png'), Row::DATATABLE_ASSOCIATED => $subtable // DataTable object // (but in the row only the ID will be stored) )

__destruct() 공개 메소드

When destroyed, a row destroys its associated subtable if there is one.
public __destruct ( )

__toString() 공개 메소드

Applies a basic rendering to the Row and returns the output.
public __toString ( ) : string
리턴 string describing the row. Example: "- 1 ['label' => 'piwik', 'nb_uniq_visitors' => 1685, 'nb_visits' => 1861] [] [idsubtable = 1375]"

addColumn() 공개 메소드

Add a new column to the row. If the column already exists, throws an exception.
public addColumn ( string $name, mixed $value )
$name string name of the column to add.
$value mixed value of the column to set or a PHP callable.

addColumns() 공개 메소드

Add many columns to this row.
public addColumns ( array $columns ) : void
$columns array Name/Value pairs, e.g., `array('name' => $value , ...)`
리턴 void

addMetadata() 공개 메소드

Add a new metadata to the row. If the metadata already exists, throws an exception.
public addMetadata ( string $name, mixed $value )
$name string name of the metadata to add.
$value mixed value of the metadata to set.

compareElements() 공개 정적인 메소드

Helper function to compare array elements
public static compareElements ( mixed $elem1, mixed $elem2 ) : boolean
$elem1 mixed
$elem2 mixed
리턴 boolean

deleteColumn() 공개 메소드

Deletes the given column.
public deleteColumn ( string $name ) : boolean
$name string The column name.
리턴 boolean `true` on success, `false` if the column does not exist.

deleteMetadata() 공개 메소드

Deletes one metadata value or all metadata values.
public deleteMetadata ( boolean | string $name = false ) : boolean
$name boolean | string Metadata name (omit to delete entire metadata).
리턴 boolean `true` on success, `false` if the column didn't exist

export() 공개 메소드

Used when archiving to serialize the Row's properties.
public export ( ) : array
리턴 array

getColumn() 공개 메소드

Returns a column by name.
public getColumn ( string $name ) : mixed | false
$name string The column name.
리턴 mixed | false The column value or false if it doesn't exist.

getColumns() 공개 메소드

Returns the array containing all the columns.
public getColumns ( ) : array
리턴 array Example: array( 'column1' => VALUE, 'label' => 'www.php.net' 'nb_visits' => 15894, )

getIdSubDataTable() 공개 메소드

If there is no such a table, returns null.
public getIdSubDataTable ( ) : integer | null
리턴 integer | null

getMetadata() 공개 메소드

Returns the array of all metadata, or one requested metadata value.
public getMetadata ( string | null $name = null ) : mixed
$name string | null The name of the metadata to return or null to return all metadata.
리턴 mixed

getSubtable() 공개 메소드

Returns the associated subtable, if one exists. Returns false if none exists.
public getSubtable ( ) : DataTable | boolean
리턴 Piwik\DataTable | boolean

hasColumn() 공개 메소드

Returns true if a column having the given name is already registered. The value will not be evaluated, it will just check whether a column exists independent of its value.
public hasColumn ( string $name ) : boolean
$name string
리턴 boolean

isEqual() 공개 정적인 메소드

Two rows are equal if: - they have exactly the same columns / metadata - they have a subDataTable associated, then we check that both of them are the same. Column order is not important.
public static isEqual ( Row $row1, Row $row2 ) : boolean
$row1 Row first to compare
$row2 Row second to compare
리턴 boolean

isSubtableLoaded() 공개 메소드

Returns true if the subtable is currently loaded in memory via {@link Piwik\DataTable\Manager}.
public isSubtableLoaded ( ) : boolean
리턴 boolean

isSummaryRow() 공개 메소드

Returns true if this row is the summary row, false if otherwise. This function depends on the label of the row, and so, is not 100% accurate.
public isSummaryRow ( ) : boolean
리턴 boolean

removeSubtable() 공개 메소드

Removes the subtable reference.
public removeSubtable ( )

renameColumn() 공개 메소드

Renames a column.
public renameColumn ( string $oldName, string $newName )
$oldName string The current name of the column.
$newName string The new name of the column.

setColumn() 공개 메소드

Set the value $value to the column called $name.
public setColumn ( string $name, mixed $value )
$name string name of the column to set.
$value mixed value of the column to set.

setColumns() 공개 메소드

Set all the columns at once. Overwrites **all** previously set columns.
public setColumns ( array $columns )
$columns array eg, `array('label' => 'www.php.net', 'nb_visits' => 15894)`

setMetadata() 공개 메소드

Set the value $value to the metadata called $name.
public setMetadata ( string $name, mixed $value )
$name string name of the metadata to set.
$value mixed value of the metadata to set.

setNonLoadedSubtableId() 공개 메소드

public setNonLoadedSubtableId ( integer $subtableId )
$subtableId integer

setSubtable() 공개 메소드

Attaches a subtable to this row, overwriting the existing subtable, if any.
public setSubtable ( DataTable $subTable ) : DataTable
$subTable Piwik\DataTable DataTable to associate to this row.
리턴 Piwik\DataTable Returns `$subTable`.

sumRow() 공개 메소드

Only the int or float values will be summed. Label columns will be ignored even if they have a numeric value. Columns in $rowToSum that don't exist in $this are added to $this.
public sumRow ( Row $rowToSum, boolean $enableCopyMetadata = true, array | boolean $aggregationOperations = false )
$rowToSum Row The row to sum to this row.
$enableCopyMetadata boolean Whether metadata should be copied or not.
$aggregationOperations array | boolean for columns that should not be summed, determine which aggregation should be used (min, max). format: `array('column name' => 'function name')`

sumRowArray() 보호된 메소드

Helper function: sums 2 values
protected sumRowArray ( number | boolean $thisColumnValue, number | array $columnToSumValue ) : array | integer
$thisColumnValue number | boolean
$columnToSumValue number | array
리턴 array | integer

sumRowMetadata() 공개 메소드

Sums the metadata in $rowToSum with the metadata in $this row.
public sumRowMetadata ( Row $rowToSum, array $aggregationOperations = [] )
$rowToSum Row
$aggregationOperations array

sumSubtable() 공개 메소드

See {@link Piwik\DataTable::addDataTable()} to learn how DataTables are summed.
public sumSubtable ( DataTable $subTable )
$subTable Piwik\DataTable Table to sum to this row's subtable.

warnWhenSummingTwoStrings() 보호된 메소드

protected warnWhenSummingTwoStrings ( $thisColumnValue, $columnToSumValue )

프로퍼티 상세

$maxVisitsSummed 공개적으로 프로퍼티

@see sumRow - implementation detail
public $maxVisitsSummed

$subtableId 공개적으로 프로퍼티

public $subtableId