Set all the columns at once. Overwrites **all** previously set columns.
public setColumns ( array $columns ) | ||
$columns | array | eg, `array('label' => 'www.php.net', 'nb_visits' => 15894)` |
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')); }
public function test_hasColumn() { $this->row->setColumns(array('test1' => 'yes', 'test2' => false, 'test3' => 5, 'test4' => array())); $this->assertFalse($this->row->hasColumn('test')); // does not exist $this->assertTrue($this->row->hasColumn('test1')); $this->assertTrue($this->row->hasColumn('test2')); // even if value is false it still exists $this->assertTrue($this->row->hasColumn('test3')); $this->assertTrue($this->row->hasColumn('test4')); }
/** * Returns a custom data table. * This data table will be converted to all available formats * when requested in the API request. * * @return DataTable */ public function getCompetitionDatatable() { $dataTable = new DataTable(); $row1 = new Row(); $row1->setColumns(array('name' => 'piwik', 'license' => 'GPL')); // Rows Metadata is useful to store non stats data for example (logos, urls, etc.) // When printed out, they are simply merged with columns $row1->setMetadata('logo', 'logo.png'); $dataTable->addRow($row1); $dataTable->addRowFromSimpleArray(array('name' => 'google analytics', 'license' => 'commercial')); return $dataTable; }