Ejemplo n.º 1
0
 /**
  * Return values for a row in the collection using a LudoDBModel as filter/parser. This will be called when
  * "model" is set in the config.
  * @param LudoDBModel $model
  * @return array
  */
 private function getValuesUsingModel(LudoDBModel $model)
 {
     $model->disableCommit();
     $ret = array();
     $key = $this->parser->getGroupBy();
     $staticValues = $model->parser->getStaticValues();
     $this->clearStoredRows();
     $i = 0;
     $j = 0;
     foreach ($this as $value) {
         if (!isset($columns)) {
             $columns = array_keys($value);
         }
         $model->clearValues();
         $model->setValues($value);
         $modelValues = $this->getValuesFromModel($model, $columns);
         $modelValues = array_merge($modelValues, $staticValues);
         if (isset($key) && isset($modelValues[$key])) {
             if (!isset($ret[$modelValues[$key]])) {
                 $ret[$modelValues[$key]] = array();
                 $j = 0;
             }
             $ret[$modelValues[$key]][$j] = $modelValues;
             $this->storeRow($ret[$modelValues[$key]][$j]);
         } else {
             $ret[$i] = $modelValues;
             $this->storeRow($ret[$i]);
             $i++;
         }
     }
     $model->enableCommit();
     return $ret;
 }