From 96a84a1e93d0bf675f40df51ffe277ce4097e027 Mon Sep 17 00:00:00 2001 From: Achim Ennenbach Date: Sun, 3 Feb 2019 19:35:45 +0100 Subject: [PATCH] fixes an issue with pdoBind not being initialized properly fixes an issue with update(), returning sometimes an object instead of the number of updated records. fixes an issue with delete(), returning sometimes an object instead of the number of deleted records --- e107_handlers/mysql_class.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/e107_handlers/mysql_class.php b/e107_handlers/mysql_class.php index aae69e739..26dce952e 100644 --- a/e107_handlers/mysql_class.php +++ b/e107_handlers/mysql_class.php @@ -1118,6 +1118,7 @@ class e_db_mysql private function _prepareUpdateArg($tableName, $arg) { + $this->pdoBind = array(); if (is_array($arg)) // Remove the need for a separate db_UpdateArray() function. { @@ -1147,7 +1148,7 @@ class e_db_mysql $new_data = ''; - $this->pdoBind = array(); + //$this->pdoBind = array(); // moved up to the beginning of the method to make sure it is initialized properly foreach ($arg['data'] as $fn => $fv) { $new_data .= ($new_data ? ', ' : ''); @@ -1221,7 +1222,8 @@ class e_db_mysql { if(is_object($result)) { - // $result = $this->rowCount(); + // make sure to return the number of records affected, instead of an object + $result = $this->rowCount(); } } else @@ -1708,8 +1710,10 @@ class e_db_mysql { if ($result = $this->mySQLresult = $this->db_Query('DELETE FROM '.$this->mySQLPrefix.$table, NULL, 'db_Delete', $debug, $log_type, $log_remark)) { + // return the number of records deleted instead of an object + $tmp = ($this->pdo) ? $this->mySQLresult->rowCount() : mysql_affected_rows($this->mySQLaccess); $this->dbError('db_Delete'); - return $result; + return $tmp; } else {