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,15 +393,28 @@ class SqlController extends Zend_Controller_Action
$parser->parse();
if ($sqlObject->hasErrors()) {
$this->view->errorMessage = implode('<br />', $sqlObject->getErrors());
}
$statements = $parser->getParsedStatements();
foreach ($statements as $statement) {
//echo "<br>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();
}
}
}
}

Datei anzeigen

@ -50,7 +50,7 @@ function setShowTableQuery()
<?php
$this->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)) {
?>
</table>
<?php
} else {
} else {
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>

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 {
background-color: red;
border-top: 1px solid #CCC;
font-weight: bold;
text-align: right;
}
table tr.thead th,table tr.thead td {