From d9a4063f87d82836e7d7fe340c5c962e0332e2e5 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 22 Jul 2016 15:49:08 +0300 Subject: Fix #4713 --- system/database/DB_query_builder.php | 13 +++++++++---- user_guide_src/source/changelog.rst | 1 + 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php index 84346a6ed..713bf18f3 100644 --- a/system/database/DB_query_builder.php +++ b/system/database/DB_query_builder.php @@ -1498,8 +1498,10 @@ abstract class CI_DB_query_builder extends CI_DB_driver { $affected_rows = 0; for ($i = 0, $total = count($this->qb_set); $i < $total; $i += $batch_size) { - $this->query($this->_insert_batch($this->protect_identifiers($table, TRUE, $escape, FALSE), $this->qb_keys, array_slice($this->qb_set, $i, $batch_size))); - $affected_rows += $this->affected_rows(); + if ($this->query($this->_insert_batch($this->protect_identifiers($table, TRUE, $escape, FALSE), $this->qb_keys, array_slice($this->qb_set, $i, $batch_size)))) + { + $affected_rows += $this->affected_rows(); + } } $this->_reset_write(); @@ -1913,8 +1915,11 @@ abstract class CI_DB_query_builder extends CI_DB_driver { $affected_rows = 0; for ($i = 0, $total = count($this->qb_set); $i < $total; $i += $batch_size) { - $this->query($this->_update_batch($this->protect_identifiers($table, TRUE, NULL, FALSE), array_slice($this->qb_set, $i, $batch_size), $this->protect_identifiers($index))); - $affected_rows += $this->affected_rows(); + if ($this->query($this->_update_batch($this->protect_identifiers($table, TRUE, NULL, FALSE), array_slice($this->qb_set, $i, $batch_size), $this->protect_identifiers($index)))) + { + $affected_rows += $this->affected_rows(); + } + $this->qb_where = array(); } diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index ed6446bb4..419859f5c 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -42,6 +42,7 @@ Bug fixes for 3.0.7 - Fixed a bug (#4691) - :doc:`File Uploading Library ` method ``data()`` returns wrong 'raw_name' when the filename extension is also contained in the raw filename. - Fixed a bug (#4679) - :doc:`Input Library ` method ``ip_address()`` errors with a matching ``$config['proxy_ips']`` IPv6 address. - Fixed a bug (#4695) - :doc:`User Agent Library ` didn't load the *config/user_agents.php* file when there's no ``User-Agent`` HTTP request header. +- Fixed a bug (#4713) - :doc:`Query Builder ` methods ``insert_batch()``, ``update_batch()`` could return wrong affected rows count. Version 3.0.6 ============= -- cgit v1.2.3-24-g4f1b