Better CSV validation
When uploading a CSV, check every entry before executing the INSERT. The checks are the same as with the normal add except that no errors are shown.
This commit is contained in:
parent
db64370815
commit
03b0c82887
@ -138,7 +138,12 @@ class AliasEditor extends Extension {
|
||||
foreach(explode("\n", $csv) as $line) {
|
||||
$parts = explode(",", $line);
|
||||
if(count($parts) == 2) {
|
||||
$database->execute("INSERT INTO aliases(oldtag, newtag) VALUES(:oldtag, :newtag)", array("oldtag" => $parts[0], "newtag" => $parts[1]));
|
||||
$pair = array("oldtag" => $parts[0], "newtag" => $parts[1]);
|
||||
if(!$database->get_row("SELECT * FROM aliases WHERE oldtag=:oldtag AND lower(newtag)=lower(:newtag)", $pair)){
|
||||
if(!$database->get_row("SELECT * FROM aliases WHERE oldtag=:newtag", array("newtag" => $pair['newtag']))){
|
||||
$database->execute("INSERT INTO aliases(oldtag, newtag) VALUES(:oldtag, :newtag)", $pair);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user