From 0348fab9bfd90cb5ef4bd1588adfbd68249edf36 Mon Sep 17 00:00:00 2001 From: Cameron Date: Sun, 7 Aug 2016 14:17:27 -0700 Subject: [PATCH] MySQL: Fix for insert with '_DUPLICATE_KEY_UPDATE' --- e107_handlers/mysql_class.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/e107_handlers/mysql_class.php b/e107_handlers/mysql_class.php index d2d143002..835eafca2 100644 --- a/e107_handlers/mysql_class.php +++ b/e107_handlers/mysql_class.php @@ -803,7 +803,7 @@ class e_db_mysql } /** - * @return int Last insert ID or false on error. When using '_DUPLICATE_KEY_UPDATE' return ID, true on update, 0 on no change and false on error. + * @return int Last insert ID or false on error. When using '_DUPLICATE_KEY_UPDATE' return ID, true on update, 0 on no change and false on error. * @param string $tableName - Name of table to access, without any language or general DB prefix * @param string/array $arg * @param string $debug @@ -859,6 +859,7 @@ class e_db_mysql $arg = array_merge($arg, $this->getFieldDefs($tableName)); } + $argUpdate = $arg; // used when DUPLICATE_KEY_UPDATE is active; // Handle 'NOT NULL' fields without a default value @@ -899,7 +900,7 @@ class e_db_mysql if($DUPEKEY_UPDATE === true) { $query .= " ON DUPLICATE KEY UPDATE "; - $query .= $this->_prepareUpdateArg($tableName, $arg); + $query .= $this->_prepareUpdateArg($tableName, $argUpdate); } }