From dfab581c9386c93e901cb8ee4c4f46bb0d2efce0 Mon Sep 17 00:00:00 2001 From: Pradeep Nayak Date: Mon, 25 Mar 2019 13:47:29 +0000 Subject: [PATCH] dev/core/issues/819, Fixed fatal error on export screen --- CRM/Export/BAO/Export.php | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/CRM/Export/BAO/Export.php b/CRM/Export/BAO/Export.php index 44d8e7ee75..7e83f46da9 100644 --- a/CRM/Export/BAO/Export.php +++ b/CRM/Export/BAO/Export.php @@ -633,8 +633,8 @@ FROM $tableName } $sqlClause[] = '(' . implode(',', $valueString) . ')'; } - - $sqlColumnString = '(id, ' . implode(',', array_keys($sqlColumns)) . ')'; + $sqlColumns = array_merge(['id' => 1], $sqlColumns); + $sqlColumnString = '(' . implode(',', array_keys($sqlColumns)) . ')'; $sqlValueString = implode(",\n", $sqlClause); @@ -657,14 +657,13 @@ VALUES $sqlValueString // also create the sql table $exportTempTable->drop(); - $sql = " - id int unsigned NOT NULL AUTO_INCREMENT, -"; - $sql .= implode(",\n", array_values($sqlColumns)); + $sql = " id int unsigned NOT NULL AUTO_INCREMENT, "; + if (!empty($sqlColumns)) { + $sql .= implode(",\n", array_values($sqlColumns)) . ','; + } + + $sql .= "\n PRIMARY KEY ( id )"; - $sql .= ", - PRIMARY KEY ( id ) -"; // add indexes for street_address and household_name if present $addIndices = array( 'street_address', -- 2.25.1