bug 644108

This commit is contained in:
Marc Delisle
2002-11-26 17:57:06 +00:00
parent 65cd68a1ef
commit b9bb61d45e
2 changed files with 17 additions and 8 deletions

View File

@@ -5,6 +5,9 @@ phpMyAdmin - Changelog
$Id$ $Id$
$Source$ $Source$
2002-11-26 Marc Delisle <lem9@users.sourceforge.net>
* sql.php3: bug 644108: incorrect affected rows count
2002-11-25 Marc Delisle <lem9@users.sourceforge.net> 2002-11-25 Marc Delisle <lem9@users.sourceforge.net>
* tbl_properties_structure.php3: wrong back link in case of errors * tbl_properties_structure.php3: wrong back link in case of errors
* sql.php3: undefined variable $sql_query when adding a bookmark * sql.php3: undefined variable $sql_query when adding a bookmark

View File

@@ -294,7 +294,9 @@ else {
$num_rows = 0; $num_rows = 0;
} }
} }
// Executes the query
// E x e c u t e t h e q u e r y
// Only if we didn't ask to see the php code (mikebeck) // Only if we didn't ask to see the php code (mikebeck)
if (!empty($GLOBALS['show_as_php']) || !empty($GLOBALS['validatequery'])) { if (!empty($GLOBALS['show_as_php']) || !empty($GLOBALS['validatequery'])) {
unset($result); unset($result);
@@ -302,6 +304,7 @@ else {
} }
else { else {
$result = @PMA_mysql_query($full_sql_query); $result = @PMA_mysql_query($full_sql_query);
// Displays an error message if required and stop parsing the script // Displays an error message if required and stop parsing the script
if (PMA_mysql_error()) { if (PMA_mysql_error()) {
$error = PMA_mysql_error(); $error = PMA_mysql_error();
@@ -312,6 +315,16 @@ else {
PMA_mysqlDie($error, $full_sql_query, '', $full_err_url); PMA_mysqlDie($error, $full_sql_query, '', $full_err_url);
} }
// Gets the number of rows affected/returned
// (This must be done immediately after the query because
// mysql_affected_rows() reports about the last query done)
if (!$is_affected) {
$num_rows = ($result) ? @mysql_num_rows($result) : 0;
} else if (!isset($num_rows)) {
$num_rows = @mysql_affected_rows();
}
// Checks if the current database has changed // Checks if the current database has changed
// This could happen if the user sends a query like "USE `database`;" // This could happen if the user sends a query like "USE `database`;"
$res = PMA_mysql_query('SELECT DATABASE() AS "db";'); $res = PMA_mysql_query('SELECT DATABASE() AS "db";');
@@ -330,13 +343,6 @@ else {
unlink($textfile); unlink($textfile);
} }
// Gets the number of rows affected/returned
if (!$is_affected) {
$num_rows = ($result) ? @mysql_num_rows($result) : 0;
} else if (!isset($num_rows)) {
$num_rows = @mysql_affected_rows();
}
// Counts the total number of rows for the same 'SELECT' query without the // Counts the total number of rows for the same 'SELECT' query without the
// 'LIMIT' clause that may have been programatically added // 'LIMIT' clause that may have been programatically added
if (empty($sql_limit_to_append)) { if (empty($sql_limit_to_append)) {