1
0
Fork 0
- added detection if one or more queries have to be executed
- added output summary fro multiple queries
Dieser Commit ist enthalten in:
DSB 2011-06-20 17:56:36 +00:00
Ursprung 22ad2d7768
Commit 2e379d8647
4 geänderte Dateien mit 94 neuen und 16 gelöschten Zeilen

Datei anzeigen

@ -393,12 +393,24 @@ class SqlController extends Zend_Controller_Action
$parser->parse(); $parser->parse();
if ($sqlObject->hasErrors()) { if ($sqlObject->hasErrors()) {
$this->view->errorMessage = implode('<br />', $sqlObject->getErrors()); $this->view->errorMessage = implode('<br />', $sqlObject->getErrors());
} } else {
$statements = $parser->getParsedStatements(); $statements = $parser->getParsedStatements();
if (sizeof($statements) > 1) {
// we have more than one query to execute
foreach ($statements as $statement) { foreach ($statements as $statement) {
//echo "<br>Extracted statement: ".$statement;
try { try {
$res = $this->_db->query($statement, Msd_Db::ARRAY_ASSOC); $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; $this->view->resultset = $res;
} catch (Exception $e) { } catch (Exception $e) {
$this->view->errorMessage = $e->getMessage(); $this->view->errorMessage = $e->getMessage();
@ -406,6 +418,7 @@ class SqlController extends Zend_Controller_Action
} }
} }
} }
}
$this->_setDynamicParams(); $this->_setDynamicParams();
$this->view->boxcontent = $query; $this->view->boxcontent = $query;
} }

Datei anzeigen

@ -50,7 +50,7 @@ function setShowTableQuery()
<?php <?php
$this->jQuery()->javascriptCaptureEnd(); $this->jQuery()->javascriptCaptureEnd();
if (isset($this->resultset)) { if (isset($this->resultset) && is_array($this->resultset)) {
$res = $this->resultset; $res = $this->resultset;
if (count($res)>0) { if (count($res)>0) {
$fieldNames = array_keys($res[0]); $fieldNames = array_keys($res[0]);
@ -89,7 +89,38 @@ if (isset($this->resultset)) {
echo '<p>' . $this->lang->L_NO_ENTRIES . '</p>'; echo '<p>' . $this->lang->L_NO_ENTRIES . '</p>';
} }
} }
if (isset($this->resultSummary)) {
$i = 1;
$totalQueries = 0;
$cycleHelper = $this->getHelper('cycle')->cycle(array('row-even', 'row-odd'));
?> ?>
<table class="bdr" summary="Table lists result sets">
<tr class="thead">
<th colspan="3"><?php echo $this->lang->L_RESULT;?>:</th>
</tr>
<tr class="thead">
<th class="right">#</th>
<th><?php echo $this->lang->L_QUERY_TYPE;?></th>
<th><?php echo $this->lang->L_NR_OF_QUERIES;?></th>
</tr>
<?php
foreach ($this->resultSummary as $type => $count) {
$totalQueries += $count;
?>
<tr class="<?php echo $cycleHelper->next();?>">
<td class="small right"><?php echo $this->numberFormat($i);?>.</td>
<td class="small"><?php echo ucfirst($type);?></td>
<td class="small right"><?php echo $this->numberFormat($count);?></td>
</tr>
<?php $i++;
} ?>
<tr class="<?php echo $cycleHelper->next();?>">
<td class="small sum">&nbsp;</td>
<td class="small sum"><?php echo $this->lang->L_SUM_TOTAL;;?></td>
<td class="small right sum"><?php echo $this->numberFormat($totalQueries);?></td>
</tr>
</table>
<?php
} ?>
</div> </div>

Datei anzeigen

@ -0,0 +1,35 @@
<?php
/**
* This file is part of MySQLDumper released under the GNU/GPL 2 license
* http://www.mysqldumper.net
*
* @package MySQLDumper
* @subpackage SQL-Parser
* @version SVN: $Rev$
* @author $Author$
*/
/**
* Class to parse MySQL CREATE statements.
* This enables you to analyze and modify MySQL queries, which the user has entered.
*
* @package MySQLDumper
* @subpackage SQL-Parser
*/
class Msd_Sql_Parser_Statement_Set implements Msd_Sql_Parser_Interface
{
/**
* Parse the statement.
*
* @param Msd_Sql_Object $statement MySQL CREATE statement.
*
* @return void
*/
public function parse(Msd_Sql_Object $sql)
{
$sql->setState('Set');
$endOfStatement = $sql->getPosition(';');
$statement = $sql->getData($endOfStatement);
return $statement;
}
}

Datei anzeigen

@ -634,9 +634,8 @@ table.border {
} }
table td.sum { table td.sum {
background-color: red; border-top: 1px solid #CCC;
font-weight: bold; font-weight: bold;
text-align: right;
} }
table tr.thead th,table tr.thead td { table tr.thead th,table tr.thead td {