aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/db
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2014-05-23 16:13:19 +0200
committerJoas Schilling <nickvergessen@gmx.de>2014-05-26 21:43:38 +0200
commitd87dba3b0527ab1590be143c13c0c0d1010e3410 (patch)
tree038aa850a34aebb1be41166799b8e94a52162d1c /phpBB/phpbb/db
parentb92eac71e49f184d1fe451a8b1b1d396768c6fb7 (diff)
downloadforums-d87dba3b0527ab1590be143c13c0c0d1010e3410.tar
forums-d87dba3b0527ab1590be143c13c0c0d1010e3410.tar.gz
forums-d87dba3b0527ab1590be143c13c0c0d1010e3410.tar.bz2
forums-d87dba3b0527ab1590be143c13c0c0d1010e3410.tar.xz
forums-d87dba3b0527ab1590be143c13c0c0d1010e3410.zip
[ticket/12570] Fix MySQL affectedrows
We always want the number of matched rows instead of changed rows, when running an update. So when mysql_info() returns the number of matched rows we return that one instead of mysql_affected_rows() PHPBB3-12570
Diffstat (limited to 'phpBB/phpbb/db')
-rw-r--r--phpBB/phpbb/db/driver/mysql.php21
1 files changed, 20 insertions, 1 deletions
diff --git a/phpBB/phpbb/db/driver/mysql.php b/phpBB/phpbb/db/driver/mysql.php
index 1a4fd364df..de4d2de9c6 100644
--- a/phpBB/phpbb/db/driver/mysql.php
+++ b/phpBB/phpbb/db/driver/mysql.php
@@ -207,7 +207,26 @@ class mysql extends \phpbb\db\driver\mysql_base
*/
function sql_affectedrows()
{
- return ($this->db_connect_id) ? @mysql_affected_rows($this->db_connect_id) : false;
+ if ($this->db_connect_id)
+ {
+ // We always want the number of matched rows
+ // instead of changed rows, when running an update.
+ // So when mysql_info() returns the number of matched rows
+ // we return that one instead of mysql_affected_rows()
+ $mysql_info = @mysql_info($this->db_connect_id);
+ if ($mysql_info !== false)
+ {
+ $match = array();
+ preg_match('#^Rows matched: (\d)+ Changed: (\d)+ Warnings: (\d)+$#', $mysql_info, $match);
+ if (isset($match[1]))
+ {
+ return $match[1];
+ }
+ }
+
+ return @mysql_affected_rows($this->db_connect_id);
+ }
+ return false;
}
/**