protected function addDimension(\OLAP\DB\Dimension $dimension, &$i, &$params, &$declare, &$fields, &$setVars, $key = true) { $i++; $params[] = $dimension->getType()->getTableName(); if ($key) { $declare[] = "DECLARE {$dimension->getTableName()}_id_var integer; "; $fields["{$dimension->getTableName()}_id"] = "{$dimension->getTableName()}_id_var"; $parentParams = []; for ($j = 0; $j < $dimension->getSetterParamsCount(); $j++) { $parentParams[] = '$' . ($j + $i); } $parentParams = implode(', ', $parentParams); if ($this->getParent()->getDimension($dimension->getTableName())) { $setVars[] = "SELECT * INTO {$dimension->getTableName()}_id_var FROM get_{$dimension->getTableName()}_id({$parentParams}); "; } } if (($parent = $dimension->getParent()) && $dimension->getTableName() != $this->getDimension('dimension_day')->getTableName()) { $this->addDimension($parent, $i, $params, $declare, $fields, $setVars, false); } }