当前位置: 首页>>代码示例>>PHP>>正文


PHP Piwik_DataTable::deleteRows方法代码示例

本文整理汇总了PHP中Piwik_DataTable::deleteRows方法的典型用法代码示例。如果您正苦于以下问题:PHP Piwik_DataTable::deleteRows方法的具体用法?PHP Piwik_DataTable::deleteRows怎么用?PHP Piwik_DataTable::deleteRows使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Piwik_DataTable的用法示例。


在下文中一共展示了Piwik_DataTable::deleteRows方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: filter

 /**
  * Applies the reduce function to each row and merges rows w/ the same reduce result.
  *
  * @param Piwik_DataTable  $table
  */
 public function filter($table)
 {
     $groupByRows = array();
     $nonGroupByRowIds = array();
     foreach ($table->getRows() as $rowId => $row) {
         // skip the summary row
         if ($rowId == Piwik_DataTable::ID_SUMMARY_ROW) {
             continue;
         }
         // reduce the group by column of this row
         $groupByColumnValue = $row->getColumn($this->groupByColumn);
         $parameters = array_merge(array($groupByColumnValue), $this->parameters);
         $groupByValue = call_user_func_array($this->reduceFunction, $parameters);
         if (!isset($groupByRows[$groupByValue])) {
             // if we haven't encountered this group by value before, we mark this row as a
             // row to keep, and change the group by column to the reduced value.
             $groupByRows[$groupByValue] = $row;
             $row->setColumn($this->groupByColumn, $groupByValue);
         } else {
             // if we have already encountered this group by value, we add this row to the
             // row that will be kept, and mark this one for deletion
             $groupByRows[$groupByValue]->sumRow($row);
             $nonGroupByRowIds[] = $rowId;
         }
     }
     // delete the unneeded rows.
     $table->deleteRows($nonGroupByRowIds);
 }
开发者ID:nnnnathann,项目名称:piwik,代码行数:33,代码来源:GroupBy.php

示例2: filter

 /**
  * Filters the given data table
  *
  * @param Piwik_DataTable  $table
  */
 public function filter($table)
 {
     $rowsIdToDelete = array();
     foreach ($table->getRows() as $key => $row) {
         $nbVisits = $this->getColumn($row, Piwik_Archive::INDEX_NB_VISITS);
         $nbActions = $this->getColumn($row, Piwik_Archive::INDEX_NB_ACTIONS);
         if ($nbVisits == 0 && $nbActions == 0 && $this->deleteRowsWithNoVisit) {
             // case of keyword/website/campaign with a conversion for this day,
             // but no visit, we don't show it
             $rowsIdToDelete[] = $key;
             continue;
         }
         $nbVisitsConverted = (int) $this->getColumn($row, Piwik_Archive::INDEX_NB_VISITS_CONVERTED);
         if ($nbVisitsConverted > 0) {
             $conversionRate = round(100 * $nbVisitsConverted / $nbVisits, $this->roundPrecision);
             try {
                 $row->addColumn('conversion_rate', $conversionRate . "%");
             } catch (Exception $e) {
                 // conversion_rate can be defined upstream apparently? FIXME
             }
         }
         if ($nbVisits == 0) {
             $actionsPerVisit = $averageTimeOnSite = $bounceRate = $this->invalidDivision;
         } else {
             // nb_actions / nb_visits => Actions/visit
             // sum_visit_length / nb_visits => Avg. Time on Site
             // bounce_count / nb_visits => Bounce Rate
             $actionsPerVisit = round($nbActions / $nbVisits, $this->roundPrecision);
             $averageTimeOnSite = round($this->getColumn($row, Piwik_Archive::INDEX_SUM_VISIT_LENGTH) / $nbVisits, $rounding = 0);
             $bounceRate = round(100 * $this->getColumn($row, Piwik_Archive::INDEX_BOUNCE_COUNT) / $nbVisits, $this->roundPrecision);
         }
         try {
             $row->addColumn('nb_actions_per_visit', $actionsPerVisit);
             $row->addColumn('avg_time_on_site', $averageTimeOnSite);
         } catch (Exception $e) {
         }
         try {
             $row->addColumn('bounce_rate', $bounceRate . "%");
         } catch (Exception $e) {
         }
         $this->filterSubTable($row);
     }
     $table->deleteRows($rowsIdToDelete);
 }
开发者ID:nnnnathann,项目名称:piwik,代码行数:49,代码来源:AddColumnsProcessedMetrics.php


注:本文中的Piwik_DataTable::deleteRows方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。