Esempio n. 1
0
 /**
  * fetch complete result set
  * @param int $type
  */
 protected function fetchResult($type = self::FETCH_ASSOC)
 {
     $this->result = new Result();
     while ($row = $this->fetch($type)) {
         $this->result->push($row);
     }
 }
Esempio n. 2
0
 public function setUp()
 {
     // create result set of 2 Rows
     $this->resultset = new Result();
     $this->resultset->push(new Row(array('ONE' => 'foo', 'TWO' => 'bar', 'THREE' => 'baz')));
     $this->resultset->push(new Row(array('ONE' => 'moo', 'TWO' => 'mar', 'THREE' => 'maz')));
 }
Esempio n. 3
0
 public function testPivotDoNotSortColumnsByColumnHeader()
 {
     // the results are odered by date
     $result = new Result();
     $rows = array(array('company' => 'Foo', 'date' => '30-03-2014', 'amount' => 2), array('company' => 'Bar', 'date' => '30-03-2014', 'amount' => 4), array('company' => 'Qux', 'date' => '30-03-2014', 'amount' => 8), array('company' => 'Foo', 'date' => '06-04-2014', 'amount' => 3), array('company' => 'Bar', 'date' => '06-04-2014', 'amount' => 9), array('company' => 'Qux', 'date' => '06-04-2014', 'amount' => 27), array('company' => 'Foo', 'date' => '13-04-2014', 'amount' => 5), array('company' => 'Bar', 'date' => '13-04-2014', 'amount' => 25), array('company' => 'Qux', 'date' => '13-04-2014', 'amount' => 125));
     foreach ($rows as $row) {
         $result->push(new Row($row));
     }
     $colHeadersField = 'date';
     $rowHeaders = 'company';
     $dataField = 'amount';
     $showTotal = false;
     $pivoter = new Pivoter($result);
     $pivoter->setSortByFirstColumn(false);
     // This would sort Bar, Foo, Qux
     $pivoter->setSortByColumnHeader(false);
     $actual = $pivoter->toPivot($colHeadersField, $rowHeaders, $dataField, $showTotal);
     $expected = array(array('company' => 'Foo', '30-03-2014' => 2, '06-04-2014' => 3, '13-04-2014' => 5), array('company' => 'Bar', '30-03-2014' => 4, '06-04-2014' => 9, '13-04-2014' => 25), array('company' => 'Qux', '30-03-2014' => 8, '06-04-2014' => 27, '13-04-2014' => 125));
     // order of the keys is important!
     // (assertEquals will pass even if they're in the wrong order)
     $this->assertTrue($expected === $actual);
 }