Some suggested changes/patch for file upload
Brought to you by:
freddy78
Hello, I have made a couple of changes to the "SQLiteTableProperties.class.php" file that might be useful for other people. Here are the changes:
Line 753, change to:
$recordElement = explode($sep, rtrim($record, "\n\r"));
That is, add "\n\r" to "rtrim" so that it doesn't get rid of trailing tabs--trailing tabs need to be there when the last item is null!
Line 754, change to:
$query[] = "INSERT OR REPLACE INTO ".brackets($this->table)." VALUES ('".implode("', '", $recordElement)."');";
By using "OR REPLACE", if there is a conflict it will update the line rather than exiting with an error and rolling back.
Thanks for supplying this code. It is extremely helpful.
I am attaching my revised file.
Best regards,
Eric
Modified "SQLiteTableProperties.class.php"
Hi, again, some additional code. Above I said that blanks are treated as "null". Of course that's not standard SQL behavior. I added the following code to make that happen, because I needed it--for many records, some of the entries must be null.
From line 753 and following:
$recordElement = array();
foreach (explode($sep, rtrim($record, "\n\r")) as $recordElementItem) {
if (trim($recordElementItem) === '') {
$recordElement[] = "null";
} else {
$recordElement[] = "'" . $recordElementItem . "'";
}
}
$query[] = "INSERT OR REPLACE INTO ".brackets($this->table)." VALUES (".implode(", ", $recordElement).");";