diff --git a/phpgwapi/inc/class.db_backup.inc.php b/phpgwapi/inc/class.db_backup.inc.php index 2fcd38f3ba..a2db0955be 100644 --- a/phpgwapi/inc/class.db_backup.inc.php +++ b/phpgwapi/inc/class.db_backup.inc.php @@ -341,10 +341,11 @@ class db_backup * @param boolean $convert_to_system_charset=true convert the restored data to the selected system-charset * @param string $filename='' gives the file name which is used in case of a zip archive. * @param boolean $protect_system_config=true should above system_config values be protected (NOT overwritten) + * @param int $insert_n_rows=10 how many rows to insert in one sql statement * * @returns An empty string or an error message in case of failure. */ - function restore($f,$convert_to_system_charset=true,$filename='',$protect_system_config=true) + function restore($f,$convert_to_system_charset=true,$filename='',$protect_system_config=true, $insert_n_rows=10) { @set_time_limit(0); ini_set('auto_detect_line_endings',true); @@ -462,6 +463,11 @@ class db_backup } if (substr($line,0,7) == 'table: ') { + if ($rows) // flush pending rows of last table + { + $this->db->insert($table,$rows,False,__LINE__,__FILE__,false,false,$this->schemas[$table]); + } + $rows = array(); $table = substr($line,7); $cols = self::csv_split($line=fgets($f)); ++$n; @@ -501,7 +507,19 @@ class db_backup { $data = translation::convert($data,$charset); } - $this->db->insert($table,$data,False,__LINE__,__FILE__,false,false,$this->schemas[$table]); + if ($insert_n_rows > 1) + { + $rows[] = $data; + if (count($rows) == $insert_n_rows) + { + $this->db->insert($table,$rows,False,__LINE__,__FILE__,false,false,$this->schemas[$table]); + $rows = array(); + } + } + else + { + $this->db->insert($table,$data,False,__LINE__,__FILE__,false,false,$this->schemas[$table]); + } } else { @@ -511,6 +529,10 @@ class db_backup } } } + if ($rows) // flush pending rows + { + $this->db->insert($table,$rows,False,__LINE__,__FILE__,false,false,$this->schemas[$table]); + } // updated the sequences, if the DB uses them foreach($this->schemas as $table => $schema) { diff --git a/phpgwapi/inc/class.egw_db.inc.php b/phpgwapi/inc/class.egw_db.inc.php index 8428a147e1..9d383c3c73 100644 --- a/phpgwapi/inc/class.egw_db.inc.php +++ b/phpgwapi/inc/class.egw_db.inc.php @@ -1787,7 +1787,25 @@ class egw_db $table = self::$tablealiases[$table]; } $inputarr = false; - if ($use_prepared_statement && $this->Link_ID->_bindInputArray) // eg. MaxDB + if (isset($data[0]) && is_array($data[0])) // multiple data rows + { + if ($where) throw new egw_exception_wrong_parameter('Can NOT use $where together with multiple data rows in $data!'); + + $sql = "$cmd INTO $table "; + foreach($data as $k => $d) + { + if (!$k) + { + $sql .= $this->column_data_implode(',',$d,'VALUES',true,$table_def['fd']); + } + else + { + $sql .= ",\n(".$this->column_data_implode(',',$d,false,true,$table_def['fd']).')'; + } + } + $sql .= $sql_append; + } + elseif ($use_prepared_statement && $this->Link_ID->_bindInputArray) // eg. MaxDB { $this->Link_ID->Param(false); // reset param-counter $cols = array_keys($data); diff --git a/setup/db_backup.php b/setup/db_backup.php index a8e0040c7c..7c030920e0 100644 --- a/setup/db_backup.php +++ b/setup/db_backup.php @@ -186,8 +186,9 @@ if ($_POST['restore']) if (is_resource($f = $db_backup->fopen_backup($file,true))) { echo '

'.lang('restore started, this might take a few minutes ...')."

\n".str_repeat(' ',4096); + $start = time(); $db_backup->restore($f, true, $file); // allways convert to current system charset on restore - $setup_tpl->set_var('error_msg',lang("backup '%1' restored",$file)); + $setup_tpl->set_var('error_msg',lang("backup '%1' restored",$file).' ('.(time()-$start).' s)'); if ($run_in_egw) { // updating the backup