本文整理汇总了PHP中Piwik\DataTable\Row::sumRow方法的典型用法代码示例。如果您正苦于以下问题:PHP Row::sumRow方法的具体用法?PHP Row::sumRow怎么用?PHP Row::sumRow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik\DataTable\Row
的用法示例。
在下文中一共展示了Row::sumRow方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_SumRow_shouldIgnoreCallableValues_AndNotRaiseAnyException
public function test_SumRow_shouldIgnoreCallableValues_AndNotRaiseAnyException()
{
$columns = array('nb_visits' => 5, 'label' => 'Test', 'closure' => function () {
return 7;
});
$this->row->setColumns($columns);
$secondRow = new Row(array(Row::COLUMNS => $columns));
$this->row->sumRow($secondRow);
$this->assertEquals(10, $this->row->getColumn('nb_visits'));
$this->assertEquals(7, $this->row->getColumn('closure'));
}
示例2: addRow
/**
* Adds a row to this table.
*
* If {@link setMaximumAllowedRows()} was called and the current row count is
* at the maximum, the new row will be summed to the summary row. If there is no summary row,
* this row is set as the summary row.
*
* @param Row $row
* @return Row `$row` or the summary row if we're at the maximum number of rows.
*/
public function addRow(Row $row)
{
// if there is a upper limit on the number of allowed rows and the table is full,
// add the new row to the summary row
if ($this->maximumAllowedRows > 0 && $this->getRowsCount() >= $this->maximumAllowedRows - 1) {
if ($this->summaryRow === null) {
// create the summary row if necessary
$columns = array('label' => self::LABEL_SUMMARY_ROW) + $row->getColumns();
$this->addSummaryRow(new Row(array(Row::COLUMNS => $columns)));
} else {
$this->summaryRow->sumRow($row, $enableCopyMetadata = false, $this->getMetadata(self::COLUMN_AGGREGATION_OPS_METADATA_NAME));
}
return $this->summaryRow;
}
$this->rows[] = $row;
if (!$this->indexNotUpToDate && $this->rebuildIndexContinuously) {
$label = $row->getColumn('label');
if ($label !== false) {
$this->rowsIndexByLabel[$label] = count($this->rows) - 1;
}
}
return $row;
}
示例3: testSumRow_stringException
/**
* Test that adding two string column values results in an exception.
*/
public function testSumRow_stringException()
{
$columns = array('super' => array('this column has an array string that will be 0 when algorithm sums the value'));
$row1 = new Row(array(Row::COLUMNS => $columns));
$columns2 = array('super' => array('this column has geagaean array value, amazing'));
$row2 = new Row(array(Row::COLUMNS => $columns2));
$row2->sumRow($row1);
$this->assertTrue($noException = true);
}
示例4: addSummaryRow
private function addSummaryRow($table)
{
$table->filter('Sort', array($this->columnToSortByBeforeTruncating, 'desc'));
if ($table->getRowsCount() <= $this->truncateAfter + 1) {
return;
}
$rows = $table->getRows();
$count = $table->getRowsCount();
$newRow = new Row(array(Row::COLUMNS => array('label' => DataTable::LABEL_SUMMARY_ROW)));
for ($i = $this->truncateAfter; $i < $count; $i++) {
if (!isset($rows[$i])) {
// case when the last row is a summary row, it is not indexed by $cout but by DataTable::ID_SUMMARY_ROW
$summaryRow = $table->getRowFromId(DataTable::ID_SUMMARY_ROW);
//FIXME: I'm not sure why it could return false, but it was reported in: http://forum.piwik.org/read.php?2,89324,page=1#msg-89442
if ($summaryRow) {
$newRow->sumRow($summaryRow, $enableCopyMetadata = false, $table->getMetadata(DataTable::COLUMN_AGGREGATION_OPS_METADATA_NAME));
}
} else {
$newRow->sumRow($rows[$i], $enableCopyMetadata = false, $table->getMetadata(DataTable::COLUMN_AGGREGATION_OPS_METADATA_NAME));
}
}
$table->filter('Limit', array(0, $this->truncateAfter));
$table->addSummaryRow($newRow);
unset($rows);
}
示例5: testSumRow_stringException
/**
* Test that adding two string column values results in an exception.
*
* @group Core
*
* @expectedException Exception
*/
public function testSumRow_stringException()
{
$columns = array('super' => array('this column has an array string that will be 0 when algorithm sums the value'));
$row1 = new Row(array(Row::COLUMNS => $columns));
$columns2 = array('super' => array('this column has geagaean array value, amazing'));
$row2 = new Row(array(Row::COLUMNS => $columns2));
$row2->sumRow($row1);
$this->fail("sumRow did not throw when adding two string columns.");
}