Commit 520b3282 authored by Carsten  Rose's avatar Carsten Rose
Browse files

Report.php: fixed problem with wrong .line.count and .line.total in subsequent queries.

parent 8bb02d49
...@@ -388,7 +388,9 @@ class Report { ...@@ -388,7 +388,9 @@ class Report {
// debug(array('full_level' => $full_level)); // debug(array('full_level' => $full_level));
} }
// Prepare SQL: replace variables. // Prepare SQL: replace variables. Actual 'line.total' or 'line.count' will recalculated: don't replace them now!
unset($this->variables->resultArray[$full_level . ".line."]["total"]);
unset($this->variables->resultArray[$full_level . ".line."]["count"]);
$sql = $this->variables->doVariables($this->frArray[$full_level . ".sql"]); $sql = $this->variables->doVariables($this->frArray[$full_level . ".sql"]);
// DEBUG // DEBUG
...@@ -428,17 +430,17 @@ class Report { ...@@ -428,17 +430,17 @@ class Report {
// record number counter // record number counter
$this->variables->resultArray[$full_level . ".line."]["count"] = ++$rowIndex; $this->variables->resultArray[$full_level . ".line."]["count"] = ++$rowIndex;
// replace ~count and ~total in result, if the variables specify their own full_level. This can't be replaced before firing the query. // replace ~<level>.line.count and ~<level>.line.total in __result__, if the variables specify their own full_level. This can't be replaced before firing the query.
for ($ii = 0; $ii < count($row); $ii++) { for ($ii = 0; $ii < count($row); $ii++) {
$row[$ii] = str_replace("~" . $full_level . ".line.count", $rowIndex, $row[$ii]); $row[$ii] = str_replace("~" . $full_level . ".line.count", $rowIndex, $row[$ii]);
$row[$ii] = str_replace("~" . $full_level . ".line.total", $rowTotal, $row[$ii]); $row[$ii] = str_replace("~" . $full_level . ".line.total", $rowTotal, $row[$ii]);
} }
// Create Assoc Array of result // Create Assoc Array of result
unset($rowAssoc); // unset($rowAssoc);
for ($i = 0; $i < count($row); $i++) { // for ($i = 0; $i < count($row); $i++) {
$rowAssoc[$keys[$i]] = $row[$i]; // $rowAssoc[$keys[$i]] = $row[$i];
} // }
// SEP set seperator (empty on first run) // SEP set seperator (empty on first run)
$content .= $columnValueSeperator; $content .= $columnValueSeperator;
...@@ -460,15 +462,8 @@ class Report { ...@@ -460,15 +462,8 @@ class Report {
// RENR // RENR
$content .= $this->variables->doVariables($this->frArray[$full_level . "." . "renr"]); $content .= $this->variables->doVariables($this->frArray[$full_level . "." . "renr"]);
// this is necessary: queries 2,3,.. should not be replaced with content of resultArray but with the most recent values. So delete the entry in resultArray.
// unset($this->variables->resultArray[$full_level . ".line."]["total"]);
// unset($this->variables->resultArray[$full_level . ".line."]["count"]);
} }
// set last valid counts again: should be available for later queries
// $this->variables->resultArray[$full_level . ".line."]["total"] = $rowTotal;
// $this->variables->resultArray[$full_level . ".line."]["count"] = $rowIndex;
//Print althead or tail //Print althead or tail
if ($rowTotal > 0) { if ($rowTotal > 0) {
$content .= $this->variables->doVariables($this->frArray[$full_level . "." . "tail"]); $content .= $this->variables->doVariables($this->frArray[$full_level . "." . "tail"]);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment