Menu

#45 Some suggested changes/patch for file upload

open-fixed
nobody
None
5
2010-01-04
2009-11-01
No

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

Discussion

  • Eric Kemp-Benedict

    Modified "SQLiteTableProperties.class.php"

     
  • Eric Kemp-Benedict

    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).");";

     
  • HENNINOT frederic

    • status: open --> open-fixed
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.