From 28dcd4ba565ec9f9471cd47ae535efed4e828785 Mon Sep 17 00:00:00 2001 From: reliberate Date: Mon, 6 Jun 2016 17:24:08 -0600 Subject: [PATCH] Command: Fix SQL insert statement generation (insert comma after null, use single-quotes instead of double). --- app/exec/sql_query_result.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/exec/sql_query_result.php b/app/exec/sql_query_result.php index a8eb39f3b1..2866f75c39 100644 --- a/app/exec/sql_query_result.php +++ b/app/exec/sql_query_result.php @@ -204,20 +204,26 @@ if (count($_POST)>0) { $x = 1; foreach ($column_array as $column) { if ($column != "menuid" && $column != "menuparentid") { - echo $column.(($x < $column_array_count) ? "," : null); + $columns[] = $column; } $x++; } - echo ") "; - echo "values ( "; + if (is_array($columns) && sizeof($columns) > 0) { + echo implode(', ', $columns); + } + echo ") values ("; $x = 1; foreach ($column_array as $column) { if ($column != "menuid" && $column != "menuparentid") { - echo (!is_null($row[$column])) ? "\"".check_str($row[$column])."\"".(($x < $column_array_count) ? ',' : null) : 'null'; + $values[] = ($row[$column] != '') ? "'".check_str($row[$column])."'" : 'null'; } $x++; } + if (is_array($values) && sizeof($values) > 0) { + echo implode(', ', $values); + } echo ");
\n"; + unset($columns, $values); } } echo $footer;