From c7d49638971e878b7f0de719b1707bcc4f57b7f4 Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Wed, 25 Jan 2006 14:49:40 +0000 Subject: [PATCH] affected rows are returned in case of DELETE with no WHERE clause, at least since MySQL 4.0.x --- sql.php | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/sql.php b/sql.php index dda4d80db..d587c4d34 100644 --- a/sql.php +++ b/sql.php @@ -353,16 +353,19 @@ else { // If the query is a DELETE query with no WHERE clause, get the number of // rows that will be deleted (mysql_affected_rows will always return 0 in // this case) + // Note: testing shows that this no longer applies since MySQL 4.0.x - if ($is_delete - && preg_match('@^DELETE([[:space:]].+)?(FROM[[:space:]](.+))$@i', $sql_query, $parts) - && !preg_match('@[[:space:]]WHERE[[:space:]]@i', $parts[3])) { - $cnt_all_result = @PMA_DBI_try_query('SELECT COUNT(*) as count ' . $parts[2]); - if ($cnt_all_result) { - list($num_rows) = PMA_DBI_fetch_row($cnt_all_result); - PMA_DBI_free_result($cnt_all_result); - } else { - $num_rows = 0; + if (PMA_MYSQL_INT_VERSION < 40000) { + if ($is_delete + && preg_match('@^DELETE([[:space:]].+)?(FROM[[:space:]](.+))$@i', $sql_query, $parts) + && !preg_match('@[[:space:]]WHERE[[:space:]]@i', $parts[3])) { + $cnt_all_result = @PMA_DBI_try_query('SELECT COUNT(*) as count ' . $parts[2]); + if ($cnt_all_result) { + list($num_rows) = PMA_DBI_fetch_row($cnt_all_result); + PMA_DBI_free_result($cnt_all_result); + } else { + $num_rows = 0; + } } }