diff options
author | Andreas Fischer <bantu@phpbb.com> | 2014-05-26 23:09:51 +0200 |
---|---|---|
committer | Andreas Fischer <bantu@phpbb.com> | 2014-05-26 23:09:51 +0200 |
commit | d646354b0e8f2d14d48c51c11d4462c7087f94c8 (patch) | |
tree | cbaffc8574a99b9022e4d3c731d1388c1ebf410e /phpBB/phpbb/db/driver/mysql.php | |
parent | 502cbad5a7f8896311a616553cff9d83ccc87497 (diff) | |
parent | fcdf1101cba7999081f12bca2f5f96ef7769539c (diff) | |
download | forums-d646354b0e8f2d14d48c51c11d4462c7087f94c8.tar forums-d646354b0e8f2d14d48c51c11d4462c7087f94c8.tar.gz forums-d646354b0e8f2d14d48c51c11d4462c7087f94c8.tar.bz2 forums-d646354b0e8f2d14d48c51c11d4462c7087f94c8.tar.xz forums-d646354b0e8f2d14d48c51c11d4462c7087f94c8.zip |
Merge pull request #2492 from nickvergessen/ticket/12570
[ticket/12570] Fix updating a config with the same value
* nickvergessen/ticket/12570:
[ticket/12570] Keep MySQLi procedural
[ticket/12570] Remove test for affected rows after SELECT
[ticket/12570] Add a test for set_array() and updating with the same value
[ticket/12570] Fix MySQL affectedrows
[ticket/12570] Fix MySQLi affectedrows by specifying MYSQLI_CLIENT_FOUND_ROWS
[ticket/12570] Add a unit test to show broken sql_affectedrows()
[ticket/12570] Add test for updating a config with the same value
Diffstat (limited to 'phpBB/phpbb/db/driver/mysql.php')
-rw-r--r-- | phpBB/phpbb/db/driver/mysql.php | 21 |
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; } /** |