mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-08 00:54:50 +01:00
* Admin/Setup: ignoring doublicate rows from old backups
This commit is contained in:
parent
8f713fe2f1
commit
debe67be86
@ -575,7 +575,7 @@ class db_backup
|
||||
{
|
||||
if ($rows) // flush pending rows of last table
|
||||
{
|
||||
$this->db->insert($table,$rows,False,__LINE__,__FILE__,false,false,$this->schemas[$table]);
|
||||
$this->insert_multiple($table, $rows, $this->schemas[$table]);
|
||||
}
|
||||
$rows = array();
|
||||
$table = substr($line,7);
|
||||
@ -631,7 +631,7 @@ class db_backup
|
||||
$rows[] = $data;
|
||||
if (count($rows) == $insert_n_rows)
|
||||
{
|
||||
$this->db->insert($table,$rows,False,__LINE__,__FILE__,false,false,$this->schemas[$table]);
|
||||
$this->insert_multiple($table, $rows, $this->schemas[$table]);
|
||||
$rows = array();
|
||||
}
|
||||
}
|
||||
@ -645,7 +645,12 @@ class db_backup
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->insert($table,$data,False,__LINE__,__FILE__,false,false,$this->schemas[$table]);
|
||||
try {
|
||||
$this->db->insert($table,$data,False,__LINE__,__FILE__,false,false,$this->schemas[$table]);
|
||||
}
|
||||
catch(egw_exception_db_invalid_sql $e) {
|
||||
echo "<p>".$e->getMessage()."</p>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -658,7 +663,7 @@ class db_backup
|
||||
}
|
||||
if ($rows) // flush pending rows
|
||||
{
|
||||
$this->db->insert($table,$rows,False,__LINE__,__FILE__,false,false,$this->schemas[$table]);
|
||||
$this->insert_multiple($table, $rows, $this->schemas[$table]);
|
||||
}
|
||||
// updated the sequences, if the DB uses them
|
||||
foreach($this->schemas as $table => $schema)
|
||||
@ -675,6 +680,33 @@ class db_backup
|
||||
return $n;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert multiple rows ignoring doublicate entries
|
||||
*
|
||||
* @param string $table
|
||||
* @param array $rows
|
||||
* @param array $schema
|
||||
*/
|
||||
private function insert_multiple($table, array $rows, array $schema)
|
||||
{
|
||||
try {
|
||||
$this->db->insert($table, $rows, False, __LINE__, __FILE__, false, false, $schema);
|
||||
}
|
||||
catch(egw_exception_db_invalid_sql $e)
|
||||
{
|
||||
// try inserting them one by one, ignoring doublicates
|
||||
foreach($rows as $data)
|
||||
{
|
||||
try {
|
||||
$this->db->insert($table, $data, False, __LINE__, __FILE__, false, false, $schema);
|
||||
}
|
||||
catch(egw_exception_db_invalid_sql $e) {
|
||||
echo "<p>".$e->getMessage()."</p>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a dir, no matter whether it is empty or full
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user