diff --git a/classes/helper.php b/classes/helper.php index 45c5740..0721ab7 100644 --- a/classes/helper.php +++ b/classes/helper.php @@ -330,8 +330,7 @@ public static function regular_expression_search(string $search, string $table, if (!empty($stream)) { if ($summary) { fputcsv($stream, [ - $table, - $column->name, + "$table:$column->name", ]); // Return empty array to skip the rest of the function. diff --git a/cli/find.php b/cli/find.php index 5c64df9..7f30b17 100644 --- a/cli/find.php +++ b/cli/find.php @@ -116,8 +116,6 @@ // Show header. if (!$options['summary']) { fputcsv($fp, ['table', 'column', 'courseid', 'shortname', 'id', 'match']); -} else { - fputcsv($fp, ['table', 'column']); } // Perform the search. @@ -146,5 +144,20 @@ } $progress->update_full(100, "Finished searching into $output"); + fclose($fp); + +if ($summary) { + // Read the content of the output file. + $filecontent = file_get_contents($output); + // Replace new line with comma. + $filecontent = str_replace("\n", ',', $filecontent); + // Remove the last comma. + $filecontent = substr($filecontent, 0, -1); + // Add a new line at the end. + $filecontent .= "\n"; + // Write the content back to the file. + file_put_contents($output, $filecontent); +} + exit(0);