From b67f21845163a7ec0f4b556e1e1d3ffdfdaad647 Mon Sep 17 00:00:00 2001 From: Carsten Rose <carsten.rose@math.uzh.ch> Date: Mon, 18 Apr 2016 18:41:40 +0200 Subject: [PATCH] Report.php: fixed bug that 'INSERT' and 'UPDATE' causes an exception. --- extension/qfq/qfq/report/Report.php | 56 +++++++++++++++-------------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/extension/qfq/qfq/report/Report.php b/extension/qfq/qfq/report/Report.php index 34b802584..c1251fd9a 100644 --- a/extension/qfq/qfq/report/Report.php +++ b/extension/qfq/qfq/report/Report.php @@ -387,40 +387,42 @@ class Report { // Prepare row alteration $arrRbgd = explode("|", $this->frArray[$full_level . "." . "rbgd"]); - //--------------------------------- - // Process each row of resultset - $columnValueSeperator = ""; - $rowIndex = 0; - foreach ($result as $row) { - // record number counter - $this->variables->resultArray[$full_level . ".line."]["count"] = ++$rowIndex; - - // 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++) { - $row[$ii] = str_replace("{{" . $full_level . ".line.count}}", $rowIndex, $row[$ii]); - $row[$ii] = str_replace("{{" . $full_level . ".line.total}}", $rowTotal, $row[$ii]); - } + if (is_array($result)) { + //--------------------------------- + // Process each row of resultset + $columnValueSeperator = ""; + $rowIndex = 0; + foreach ($result as $row) { + // record number counter + $this->variables->resultArray[$full_level . ".line."]["count"] = ++$rowIndex; + + // 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++) { + $row[$ii] = str_replace("{{" . $full_level . ".line.count}}", $rowIndex, $row[$ii]); + $row[$ii] = str_replace("{{" . $full_level . ".line.total}}", $rowTotal, $row[$ii]); + } - // SEP set seperator (empty on first run) - $content .= $columnValueSeperator; - $columnValueSeperator = $this->variables->doVariables($this->frArray[$full_level . "." . "rsep"]); + // SEP set seperator (empty on first run) + $content .= $columnValueSeperator; + $columnValueSeperator = $this->variables->doVariables($this->frArray[$full_level . "." . "rsep"]); - // RBGD: even/odd rows - $content .= str_replace("rbgd", $arrRbgd[$rowIndex % 2], $this->frArray[$full_level . "." . "rbeg"]); + // RBGD: even/odd rows + $content .= str_replace("rbgd", $arrRbgd[$rowIndex % 2], $this->frArray[$full_level . "." . "rbeg"]); - //----------------------------- - // COLUMNS: Collect all columns - $content .= $this->collectRow($row, $keys, $full_level, $rowIndex); + //----------------------------- + // COLUMNS: Collect all columns + $content .= $this->collectRow($row, $keys, $full_level, $rowIndex); - // REND - $content .= $this->variables->doVariables($this->frArray[$full_level . "." . "rend"]); + // REND + $content .= $this->variables->doVariables($this->frArray[$full_level . "." . "rend"]); - // Trigger subqueries of this level - $content .= $this->triggerReport($cur_level + 1, $this->indexArray[$counter], $counter + 1); + // Trigger subqueries of this level + $content .= $this->triggerReport($cur_level + 1, $this->indexArray[$counter], $counter + 1); - // RENR - $content .= $this->variables->doVariables($this->frArray[$full_level . "." . "renr"]); + // RENR + $content .= $this->variables->doVariables($this->frArray[$full_level . "." . "renr"]); + } } //Print althead or tail -- GitLab