Ejemplo n.º 1
0
 /**
  * Return the pivot table as array
  *
  * @return  array
  */
 public function toArray()
 {
     $pivot = array();
     $xAxis = $this->xAxisQuery->fetchColumn();
     $yAxis = $this->yAxisQuery->fetchColumn();
     if (!empty($xAxis) && !empty($yAxis)) {
         $this->baseQuery->where($this->xAxisColumn, $xAxis)->where($this->yAxisColumn, $yAxis);
         foreach ($yAxis as $yLabel) {
             foreach ($xAxis as $xLabel) {
                 $pivot[$yLabel][$xLabel] = null;
             }
         }
         foreach ($this->baseQuery->fetchAll() as $row) {
             $pivot[$row->{$this->yAxisColumn}][$row->{$this->xAxisColumn}] = $row;
         }
     }
     return $pivot;
 }