gendoc fixes, cube docs need fixing

This commit is contained in:
Hash Borgir
2023-08-14 01:17:48 -06:00
parent 9dc93cbcbd
commit a60492e230
2 changed files with 31 additions and 20 deletions

View File

@@ -43,9 +43,6 @@ if ($result) {
// Define the path to the TSV file
$tsvFilePath = $_SESSION['path'] . "/treasureclassex.txt";
// Open the file for writing
$fileHandle = fopen($tsvFilePath, 'w');
@@ -56,22 +53,18 @@ $query = "SELECT * FROM treasureclassex";
$result = $db->query($query);
// Write the column headers to the file
$columnNames = $result->numColumns();
$headers = [];
for ($i = 0; $i < $columnNames; $i++) {
$headers[] = $result->columnName($i);
$columnNames = [];
for ($i = 0; $i < $result->numColumns(); $i++) {
$columnNames[] = $result->columnName($i);
}
fputcsv($fileHandle, $headers, "\t");
fwrite($fileHandle, implode("\t", $columnNames) . "\n");
// Write the rows to the file
while ($row = $result->fetchArray(SQLITE3_ASSOC)) {
fputcsv($fileHandle, $row, "\t");
while ($row = $result->fetchArray(SQLITE3_NUM)) {
fwrite($fileHandle, implode("\t", $row) . "\n");
}
// Close the file
fclose($fileHandle);
echo "Successfully updated and written to TSV file!";
// Close the database connection
$db->close();
echo "Successfully updated and written to TSV file!";