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


PHP DataTable::addDataTable方法代码示例

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


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

示例1: getOverviewFromGoalTables

 protected function getOverviewFromGoalTables($tableByGoal)
 {
     $overview = new DataTable();
     foreach ($tableByGoal as $idGoal => $table) {
         if ($this->isStandardGoal($idGoal)) {
             $overview->addDataTable($table);
         }
     }
     return $overview;
 }
开发者ID:a4tunado,项目名称:piwik,代码行数:10,代码来源:Archiver.php

示例2: getByDayOfWeek

 /**
  * Returns datatable describing the number of visits for each day of the week.
  *
  * @param string $idSite The site ID. Cannot refer to multiple sites.
  * @param string $period The period type: day, week, year, range...
  * @param string $date The start date of the period. Cannot refer to multiple dates.
  * @param bool|string $segment The segment.
  * @throws Exception
  * @return DataTable
  */
 public function getByDayOfWeek($idSite, $period, $date, $segment = false)
 {
     Piwik::checkUserHasViewAccess($idSite);
     // metrics to query
     $metrics = Metrics::getVisitsMetricNames();
     unset($metrics[Metrics::INDEX_MAX_ACTIONS]);
     // disabled for multiple dates
     if (Period::isMultiplePeriod($date, $period)) {
         throw new Exception("VisitTime.getByDayOfWeek does not support multiple dates.");
     }
     // get metric data for every day within the supplied period
     $oPeriod = Period\Factory::makePeriodFromQueryParams(Site::getTimezoneFor($idSite), $period, $date);
     $dateRange = $oPeriod->getDateStart()->toString() . ',' . $oPeriod->getDateEnd()->toString();
     $archive = Archive::build($idSite, 'day', $dateRange, $segment);
     // disabled for multiple sites
     if (count($archive->getParams()->getIdSites()) > 1) {
         throw new Exception("VisitTime.getByDayOfWeek does not support multiple sites.");
     }
     $dataTable = $archive->getDataTableFromNumeric($metrics)->mergeChildren();
     // if there's no data for this report, don't bother w/ anything else
     if ($dataTable->getRowsCount() == 0) {
         return $dataTable;
     }
     // group by the day of the week (see below for dayOfWeekFromDate function)
     $dataTable->filter('GroupBy', array('label', __NAMESPACE__ . '\\dayOfWeekFromDate'));
     // create new datatable w/ empty rows, then add calculated datatable
     $rows = array();
     foreach (array(1, 2, 3, 4, 5, 6, 7) as $day) {
         $rows[] = array('label' => $day, 'nb_visits' => 0);
     }
     $result = new DataTable();
     $result->addRowsFromSimpleArray($rows);
     $result->addDataTable($dataTable);
     // set day of week integer as metadata
     $result->filter('ColumnCallbackAddMetadata', array('label', 'day_of_week'));
     // translate labels
     $result->filter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\\translateDayOfWeek'));
     // set datatable metadata for period start & finish
     $result->setMetadata('date_start', $oPeriod->getDateStart());
     $result->setMetadata('date_end', $oPeriod->getDateEnd());
     return $result;
 }
开发者ID:carriercomm,项目名称:piwik,代码行数:52,代码来源:API.php

示例3: getRowCountsByArchiveName

 /**
  * Utility function. Gets row count of a set of tables grouped by the 'name' column.
  * This is the implementation of the getRowCountsAndSizeBy... functions.
  */
 private function getRowCountsByArchiveName($statuses, $getRowSizeMethod, $forceCache = false, $otherSelects = array(), $otherDataTableColumns = array())
 {
     $extraCols = '';
     if (!empty($otherSelects)) {
         $extraCols = ', ' . implode(', ', $otherSelects);
     }
     $cols = array_merge(array('row_count'), $otherDataTableColumns);
     $dataTable = new DataTable();
     foreach ($statuses as $status) {
         $dataTableOptionName = $this->getCachedOptionName($status['Name'], 'byArchiveName');
         // if option exists && !$forceCache, use the cached data, otherwise create the
         $cachedData = Option::get($dataTableOptionName);
         if ($cachedData !== false && !$forceCache) {
             $table = DataTable::fromSerializedArray($cachedData);
         } else {
             $table = new DataTable();
             $table->addRowsFromSimpleArray($this->dataAccess->getRowCountsByArchiveName($status['Name'], $extraCols));
             $reduceArchiveRowName = array($this, 'reduceArchiveRowName');
             $table->filter('GroupBy', array('label', $reduceArchiveRowName));
             $serializedTables = $table->getSerialized();
             $serializedTable = reset($serializedTables);
             Option::set($dataTableOptionName, $serializedTable);
         }
         // add estimated_size column
         $getEstimatedSize = array($this, $getRowSizeMethod);
         $table->filter('ColumnCallbackAddColumn', array($cols, 'estimated_size', $getEstimatedSize, array($status)));
         $dataTable->addDataTable($table);
     }
     return $dataTable;
 }
开发者ID:carriercomm,项目名称:piwik,代码行数:34,代码来源:MySQLMetadataProvider.php

示例4: testAddDataTable2times

 /**
  * test add 2 different tables to the same table
  */
 public function testAddDataTable2times()
 {
     $idcol = Row::COLUMNS;
     $rows = array(array($idcol => array('label' => 'google', 'visits' => 1)), array($idcol => array('label' => 'ask', 'visits' => 0)), array($idcol => array('label' => '123', 'visits' => 2)), DataTable::ID_SUMMARY_ROW => array($idcol => array('label' => DataTable::LABEL_SUMMARY_ROW, 'visits' => 1)));
     $table = new DataTable();
     $table->addRowsFromArray($rows);
     $rows2 = array(array($idcol => array('label' => 'google2', 'visits' => -1)), array($idcol => array('label' => 'ask', 'visits' => 100)), array($idcol => array('label' => '123456', 'visits' => 1.5)));
     $table2 = new DataTable();
     $table2->addRowsFromArray($rows2);
     $rows3 = array(array($idcol => array('label' => 'google2', 'visits' => -1)), array($idcol => array('label' => 'ask', 'visits' => -10)), array($idcol => array('label' => '123ab', 'visits' => 1.5)), DataTable::ID_SUMMARY_ROW => array($idcol => array('label' => DataTable::LABEL_SUMMARY_ROW, 'visits' => 3)));
     $table3 = new DataTable();
     $table3->addRowsFromArray($rows3);
     // add the 2 tables
     $table->addDataTable($table2);
     $table->addDataTable($table3);
     $rowsExpected = array(array($idcol => array('label' => 'google', 'visits' => 1)), array($idcol => array('label' => 'ask', 'visits' => 90)), array($idcol => array('label' => '123', 'visits' => 2)), array($idcol => array('label' => 'google2', 'visits' => -2)), array($idcol => array('label' => '123456', 'visits' => 1.5)), array($idcol => array('label' => '123ab', 'visits' => 1.5)), DataTable::ID_SUMMARY_ROW => array($idcol => array('label' => DataTable::LABEL_SUMMARY_ROW, 'visits' => 4)));
     $tableExpected = new DataTable();
     $tableExpected->addRowsFromArray($rowsExpected);
     $this->assertTrue(DataTable::isEqual($table, $tableExpected));
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:23,代码来源:DataTableTest.php

示例5: preProcessSummaryStats

 /**
  * Accumulate items on the stats datatable.
  *
  * @param \Piwik\DataTable $table
  * @param $idSite
  * @param $period
  * @param $date
  * @param $type
  * @throws \Exception
  */
 protected function preProcessSummaryStats(\Piwik\DataTable &$table, $idSite, $period, $date, $type)
 {
     $base_url = "https://www.humanitarianresponse.info/api/v1.0/{$type}/?fields=id,label";
     if ($data_json = @file_get_contents($base_url)) {
         $data = json_decode($data_json);
         foreach ($data->data as $item) {
             $settings = $this->prepareSettingsForSpaceSummary($item->id, $type, $item->label);
             $datatable = $this->processSummary($idSite, $period, $date, $settings, false);
             $table->addDataTable($datatable);
         }
     }
 }
开发者ID:humanitarianresponse,项目名称:piwik_plugin,代码行数:22,代码来源:API.php


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