diff --git a/application/controllers/SqlController.php b/application/controllers/SqlController.php index f501fb3..06d34fb 100644 --- a/application/controllers/SqlController.php +++ b/application/controllers/SqlController.php @@ -393,15 +393,28 @@ class SqlController extends Zend_Controller_Action $parser->parse(); if ($sqlObject->hasErrors()) { $this->view->errorMessage = implode('
', $sqlObject->getErrors()); - } - $statements = $parser->getParsedStatements(); - foreach ($statements as $statement) { - //echo "
Extracted statement: ".$statement; - try { - $res = $this->_db->query($statement, Msd_Db::ARRAY_ASSOC); - $this->view->resultset = $res; - } catch (Exception $e) { - $this->view->errorMessage = $e->getMessage(); + } else { + $statements = $parser->getParsedStatements(); + if (sizeof($statements) > 1) { + // we have more than one query to execute + foreach ($statements as $statement) { + try { + $this->_db->query($statement, Msd_Db::ARRAY_ASSOC); + } catch (Exception $e) { + $this->view->errorMessage = $e->getMessage(); + } + } + $summary = $parser->getSummary(); + $this->view->resultSummary = $summary; + } else { + // process one query + try { + $res = $this->_db->query($statements[0], Msd_Db::ARRAY_ASSOC); + print_r($res); + $this->view->resultset = $res; + } catch (Exception $e) { + $this->view->errorMessage = $e->getMessage(); + } } } } diff --git a/application/views/scripts/sql/sqlbox/sqlbox.phtml b/application/views/scripts/sql/sqlbox/sqlbox.phtml index 2313a00..6e1300e 100644 --- a/application/views/scripts/sql/sqlbox/sqlbox.phtml +++ b/application/views/scripts/sql/sqlbox/sqlbox.phtml @@ -50,7 +50,7 @@ function setShowTableQuery() jQuery()->javascriptCaptureEnd(); -if (isset($this->resultset)) { +if (isset($this->resultset) && is_array($this->resultset)) { $res = $this->resultset; if (count($res)>0) { $fieldNames = array_keys($res[0]); @@ -85,11 +85,42 @@ if (isset($this->resultset)) { ?> ' . $this->lang->L_NO_ENTRIES . '

'; } } + +if (isset($this->resultSummary)) { + $i = 1; + $totalQueries = 0; + $cycleHelper = $this->getHelper('cycle')->cycle(array('row-even', 'row-odd')); ?> - - - + + + + + + + + + + resultSummary as $type => $count) { + $totalQueries += $count; + ?> + + + + + + + + + + + +
lang->L_RESULT;?>:
#lang->L_QUERY_TYPE;?>lang->L_NR_OF_QUERIES;?>
numberFormat($i);?>.numberFormat($count);?>
 lang->L_SUM_TOTAL;;?>numberFormat($totalQueries);?>
+ + \ No newline at end of file diff --git a/library/Msd/Sql/Parser/Statement/Set.php b/library/Msd/Sql/Parser/Statement/Set.php new file mode 100644 index 0000000..09f4518 --- /dev/null +++ b/library/Msd/Sql/Parser/Statement/Set.php @@ -0,0 +1,35 @@ +setState('Set'); + $endOfStatement = $sql->getPosition(';'); + $statement = $sql->getData($endOfStatement); + return $statement; + } +} diff --git a/public/css/msd/style.css b/public/css/msd/style.css index fcdd921..b1d54ad 100644 --- a/public/css/msd/style.css +++ b/public/css/msd/style.css @@ -634,9 +634,8 @@ table.border { } table td.sum { - background-color: red; + border-top: 1px solid #CCC; font-weight: bold; - text-align: right; } table tr.thead th,table tr.thead td {