Skip to content
Permalink
Browse files

Bug: 14216 Attempt to report back meaningful results.

For non-select statements, report back number of rows affected.
  • Loading branch information...
mrubinsk committed Jan 6, 2016
1 parent 17a1ac3 commit 3b986c3d83fcea9c7c800232897c962810d38315
Showing with 42 additions and 5 deletions.
  1. +42 −5 admin/sqlshell.php
@@ -39,11 +39,35 @@
$q_cache = array_slice($q_cache, -20);
$session->set('horde', 'sql_query_cache', $q_cache);
// Parse out the query results.
try {
$result = $db->select(Horde_String::convertCharset($command, 'UTF-8', $conf['sql']['charset']));
} catch (Horde_Db_Exception $e) {
$notification->push($e);
if (stripos($command, 'UPDATE') === 0) {
$type = 'update';
try {
$result = $db->update(Horde_String::convertCharset($command, 'UTF-8', $conf['sql']['charset']));
} catch (Horde_Db_Exception $e) {
$notification->push($e);
}
} elseif (stripos($command, 'INSERT') === 0) {
$type = 'insert';
try {
$result = $db->insert(Horde_String::convertCharset($command, 'UTF-8', $conf['sql']['charset']));
} catch (Horde_Db_Exception $e) {
$notification->push($e);
}
} elseif (stripos($command, 'DELETE') === 0) {
$type = 'delete';
try {
$result = $db->delete(Horde_String::convertCharset($command, 'UTF-8', $conf['sql']['charset']));
} catch (Horde_Db_Exception $e) {
$notification->push($e);
}
} else {
// Default to a SELECT and hope for the best.
$type = 'select';
try {
$result = $db->select(Horde_String::convertCharset($command, 'UTF-8', $conf['sql']['charset']));
} catch (Horde_Db_Exception $e) {
$notification->push($e);
}
}
}
@@ -59,6 +83,19 @@
$view->q_cache = $q_cache;
$view->title = $title;
switch ($type) {
case 'insert':
$notification->push(_("The INSERT command completed successfully."), 'horde.success');
unset($result);
break;
case 'update':
$notification->push(sprintf(_("The UPDATE command completed successfully. A total of %d rows were modified."), $result), 'horde.success');
unset($result);
break;
case 'delete':
$notification->push(sprintf(_("The DELETE command completed successfully. A total of %d rows were deleted."), $result), 'horde.success');
}
if (isset($result)) {
$keys = null;
$rows = array();

0 comments on commit 3b986c3

Please sign in to comment.
You can’t perform that action at this time.