當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Row::sumRow方法代碼示例

本文整理匯總了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'));
 }
開發者ID:a4tunado,項目名稱:piwik,代碼行數:11,代碼來源:RowTest.php

示例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;
 }
開發者ID:piwik,項目名稱:piwik,代碼行數:33,代碼來源:DataTable.php

示例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);
 }
開發者ID:FluentDevelopment,項目名稱:piwik,代碼行數:12,代碼來源:DataTableTest.php

示例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);
 }
開發者ID:KiwiJuicer,項目名稱:handball-dachau,代碼行數:25,代碼來源:Truncate.php

示例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.");
 }
開發者ID:TensorWrenchOSS,項目名稱:piwik,代碼行數:16,代碼來源:DataTableTest.php


注:本文中的Piwik\DataTable\Row::sumRow方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。