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


PHP DataTable::addRowFromArray方法代码示例

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


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

示例1: getEvenUnevenTimes

 /**
  * API method that returns number of visits based on hour parity.
  * @param int    $idSite
  * @param string $period
  * @param string $date
  * @param bool|string $segment
  * @return DataTable
  */
 public function getEvenUnevenTimes($idSite, $period, $date, $segment = false)
 {
     $archive = Archive::build($idSite, $period, $date);
     $oddHoursCount = $archive->getNumeric(Archiver::ODD_HOURS_COUNT_RECORD_NAME);
     $evenHoursCount = $archive->getNumeric(Archiver::EVEN_HOURS_COUNT_RECORD_NAME);
     $table = new DataTable();
     $table->setTableSortedBy('times');
     $table->addRowFromArray(array(Row::COLUMNS => array('times' => Piwik::translate('HourParity_Oddhours'), 'nb_visits' => $oddHoursCount)));
     $table->addRowFromArray(array(Row::COLUMNS => array('times' => Piwik::translate('HourParity_Evenhours'), 'nb_visits' => $evenHoursCount)));
     return $table;
 }
开发者ID:MichalKrakiewicz,项目名称:HourParity,代码行数:19,代码来源:API.php

示例2: testConsoleSimple

 /**
  *  test with a row without child
  *
  * @group Core
  */
 public function testConsoleSimple()
 {
     $table = new DataTable();
     $table->addRowFromArray(array(Row::COLUMNS => array('visits' => 245, 'visitors' => 245), Row::METADATA => array('logo' => 'test.png')));
     $expected = "- 1 ['visits' => 245, 'visitors' => 245] ['logo' => 'test.png'] [idsubtable = ]<br />\n";
     $render = new Console();
     $render->setTable($table);
     $rendered = $render->render();
     $this->assertEquals($expected, $rendered);
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:15,代码来源:ConsoleTest.php

示例3: getExampleReport

 /**
  * Another example method that returns a data table.
  * @param int    $idSite
  * @param string $period
  * @param string $date
  * @param bool|string $segment
  * @return DataTable
  */
 public function getExampleReport($idSite, $period, $date, $segment = false)
 {
     $table = new DataTable();
     $table->addRowFromArray(array(Row::COLUMNS => array('nb_visits' => 5)));
     return $table;
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:14,代码来源:API.php

示例4: createDataTable

 private function createDataTable($rows)
 {
     $useless1 = new DataTable();
     foreach ($rows as $row) {
         $useless1->addRowFromArray(array(Row::COLUMNS => $row));
     }
     return $useless1;
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:8,代码来源:DataTableTest.php

示例5: addRow

 private function addRow(DataTable $table, DataTable\Row $row, $growthPercentage, $newValue, $oldValue, $difference, $disappeared = false, $isNew = false, $isMover = false)
 {
     $columns = $row->getColumns();
     $columns['growth_percent'] = $growthPercentage;
     $columns['growth_percent_numeric'] = str_replace('%', '', $growthPercentage);
     $columns['grown'] = '-' != substr($growthPercentage, 0, 1);
     $columns['value_old'] = $oldValue;
     $columns['value_new'] = $newValue;
     $columns['difference'] = $difference;
     $columns['importance'] = abs($difference);
     $columns['isDisappeared'] = $disappeared;
     $columns['isNew'] = $isNew;
     $columns['isMover'] = $isMover;
     $table->addRowFromArray(array(DataTable\Row::COLUMNS => $columns));
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:15,代码来源:Insight.php

示例6: testGeneral

 /**
  * General tests that tries to test the normal behaviour of DataTable
  *
  * We create some tables, add rows, some of the rows link to sub tables
  *
  * Then we serialize everything, and we check that the unserialize give the same object back
  *
  * @group Core
  */
 public function testGeneral()
 {
     /*
      * create some fake tables to make sure that the serialized array of the first TABLE
      * does not take in consideration those tables
      */
     $useless1 = new DataTable();
     $useless1->addRowFromArray(array(Row::COLUMNS => array(13)));
     /*
      * end fake tables
      */
     /*
      * MAIN TABLE
      */
     $table = new DataTable();
     $subtable = new DataTable();
     $idtable = $table->getId();
     $idsubtable = $subtable->getId();
     /*
      * create some fake tables to make sure that the serialized array of the first TABLE
      * does not take in consideration those tables
      * -> we check that the DataTable_Manager is not impacting DataTable
      */
     $useless1->addRowFromArray(array(Row::COLUMNS => array(8487)));
     $useless3 = new DataTable();
     $useless3->addRowFromArray(array(Row::COLUMNS => array(8487)));
     /*
      * end fake tables
      */
     $row = array(Row::COLUMNS => array(0 => 1554, 1 => 42, 2 => 657, 3 => 155744), Row::METADATA => array('logo' => 'test.png'));
     $row = new Row($row);
     $table->addRow($row);
     $table->addRowFromArray(array(Row::COLUMNS => array(0 => 1554, 1 => 42), Row::METADATA => array('url' => 'piwik.org')));
     $table->addRowFromArray(array(Row::COLUMNS => array(0 => 787877888787), Row::METADATA => array('url' => 'OUPLA ADDED'), Row::DATATABLE_ASSOCIATED => $subtable));
     /*
      * SUB TABLE
      */
     $row = array(Row::COLUMNS => array(0 => 1554), Row::METADATA => array('searchengine' => 'google'));
     $subtable->addRowFromArray($row);
     $row = array(Row::COLUMNS => array(0 => 84894), Row::METADATA => array('searchengine' => 'yahoo'));
     $subtable->addRowFromArray($row);
     $row = array(Row::COLUMNS => array(0 => 4898978989), Row::METADATA => array('searchengine' => 'ask'));
     $subtable->addRowFromArray($row);
     /*
      * SUB SUB TABLE
      */
     $subsubtable = new DataTable();
     $subsubtable->addRowFromArray(array(Row::COLUMNS => array(245), Row::METADATA => array('yes' => 'subsubmetadata1')));
     $subsubtable->addRowFromArray(array(Row::COLUMNS => array(13), Row::METADATA => array('yes' => 'subsubmetadata2')));
     $row = array(Row::COLUMNS => array(0 => 666666666666666), Row::METADATA => array('url' => 'NEW ROW ADDED'), Row::DATATABLE_ASSOCIATED => $subsubtable);
     $subtable->addRowFromArray($row);
     $idsubsubtable = $subsubtable->getId();
     $serialized = $table->getSerialized();
     $this->assertEquals(array_keys($serialized), array($idsubsubtable, $idsubtable, 0));
     // In the next test we compare an unserialized datatable with its original instance.
     // The unserialized datatable rows will have positive DATATABLE_ASSOCIATED ids.
     // Positive DATATABLE_ASSOCIATED ids mean that the associated sub-datatables are not loaded in memory.
     // In this case, this is NOT true: we know that the sub-datatable is loaded in memory.
     // HOWEVER, because of datatable id conflicts happening in the datatable manager, it is not yet
     // possible to know, after unserializing a datatable, if its sub-datatables are loaded in memory.
     $expectedTableRows = array();
     foreach ($table->getRows() as $currentRow) {
         $expectedTableRow = clone $currentRow;
         $currentRowAssociatedDatatableId = $currentRow->c[Row::DATATABLE_ASSOCIATED];
         if ($currentRowAssociatedDatatableId != null) {
             // making DATATABLE_ASSOCIATED ids positive
             $expectedTableRow->c[Row::DATATABLE_ASSOCIATED] = -1 * $currentRowAssociatedDatatableId;
         }
         $expectedTableRows[] = $expectedTableRow;
     }
     $tableAfter = new DataTable();
     $tableAfter->addRowsFromSerializedArray($serialized[0]);
     $this->assertEquals($expectedTableRows, $tableAfter->getRows());
     $subsubtableAfter = new DataTable();
     $subsubtableAfter->addRowsFromSerializedArray($serialized[$idsubsubtable]);
     $this->assertEquals($subsubtable->getRows(), $subsubtableAfter->getRows());
     $this->assertEquals($subsubtable->getRows(), DataTable::fromSerializedArray($serialized[$idsubsubtable])->getRows());
     $this->assertTrue($subsubtable->getRowsCount() > 0);
     $this->assertEquals($table, Manager::getInstance()->getTable($idtable));
     $this->assertEquals($subsubtable, Manager::getInstance()->getTable($idsubsubtable));
 }
开发者ID:TensorWrenchOSS,项目名称:piwik,代码行数:90,代码来源:DataTableTest.php

示例7: getVisitorEmailFromJson

 public function getVisitorEmailFromJson($json_data)
 {
     \Piwik\Piwik::checkUserHasSomeViewAccess();
     $table = new DataTable();
     $iterator = new RecursiveIteratorIterator(new RecursiveArrayIterator(json_decode($json_data)));
     foreach ($iterator as $key => $value) {
         if (filter_var($value, FILTER_VALIDATE_EMAIL) && !in_array($value, $result)) {
             $result[] = $value;
         }
     }
     foreach ($result as $email) {
         $table->addRowFromArray(array(Row::COLUMNS => array('email' => $email, 'idvisitor' => $idvisitor)));
     }
     return $table;
 }
开发者ID:spletnik,项目名称:snoopy-behavioral-scoring,代码行数:15,代码来源:API.php

示例8: getFrontEndPerformance

 /**
  * Another example method that returns a data table.
  * @param int    $idSite
  * @param string $period
  * @param string $date
  * @param bool|string $segment
  * @return DataTable
  */
 public function getFrontEndPerformance($idSite, $period, $date, $segment = false)
 {
     $table = new DataTable();
     $table->addRowFromArray(array(Row::COLUMNS => array('nb_visits' => 5)));
     return $table;
 }
开发者ID:bokeyy,项目名称:FrontEndPerformance,代码行数:14,代码来源:API.php


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