From c0a9156f0e6bbd3686db4d6076a3c8c18307ba9d Mon Sep 17 00:00:00 2001 From: OpenXE <> Date: Mon, 7 Aug 2023 13:12:57 +0200 Subject: [PATCH] Bugfix MysqlCopyRow NULL values are converted to empty string --- phpwf/plugins/class.mysql.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/phpwf/plugins/class.mysql.php b/phpwf/plugins/class.mysql.php index 8cbeb1e5..f47f3f96 100644 --- a/phpwf/plugins/class.mysql.php +++ b/phpwf/plugins/class.mysql.php @@ -1424,7 +1424,7 @@ class DB{ if(empty($TableName) || empty($IDFieldName) || empty($IDToDuplicate)) { return null; } - +/* $sql = "SELECT * FROM $TableName WHERE $IDFieldName = $IDToDuplicate"; $result = @mysqli_query($this->connection,$sql); if(empty($result)) { @@ -1442,6 +1442,23 @@ class DB{ } $sql .= $RowKeys[$i] . " = '" . $this->real_escape_string($RowValues[$i]) . "'"; } + + @mysqli_query($this->connection,$sql); +*/ + + $sql = "INSERT INTO ".$TableName." SELECT "; + $fields = $this->GetColAssocArray($TableName); + $comma = ""; + foreach ($fields as $field => $value) { + if ($field != $IDFieldName) { + $sql .= $comma."`".$field."`"; + } else { + $sql .= "NULL"; + } + $comma = ", "; + } + $sql .= " FROM ".$TableName." WHERE id = ".$IDToDuplicate; + @mysqli_query($this->connection,$sql); $id = $this->GetInsertID();