diff options
Diffstat (limited to '')
-rw-r--r-- | admin/include/functions.php | 49 | ||||
-rw-r--r-- | include/config_default.inc.php | 8 |
2 files changed, 45 insertions, 12 deletions
diff --git a/admin/include/functions.php b/admin/include/functions.php index a7fd10e36..2e3b428f8 100644 --- a/admin/include/functions.php +++ b/admin/include/functions.php @@ -521,48 +521,73 @@ function get_fs_directories($path, $recursive = true) */ function mass_inserts($table_name, $dbfields, $datas) { + global $conf; + if (count($datas) != 0) { // inserts all found categories - $query = ' + $query_begin = ' INSERT INTO '.$table_name.' ('.implode(',', $dbfields).') VALUES'; - $first = 1; + + $first = true; + $query_value = array(); + $query_value_index = 0; + foreach ($datas as $insert) { - $query.= ' + $query_value[$query_value_index] .= ' '; if ($first) { - $first = 0; + $first = false; + if (strlen($query_value[$query_value_index]) > 6) + { + $query_value[$query_value_index] .= ','; + } } else { - $query.= ','; + if (strlen($query_value[$query_value_index]) >= $conf['max_allowed_packet']) + { + $query_value_index ++; + $query_value[$query_value_index] .= ' + '; + $first = true; + } + else + { + $query_value[$query_value_index] .= ','; + } } - $query.= '('; + $query_value[$query_value_index] .= '('; foreach ($dbfields as $field_id => $dbfield) { if ($field_id > 0) { - $query.= ','; + $query_value[$query_value_index] .= ','; } if (!isset($insert[$dbfield]) or $insert[$dbfield] === '') { - $query.= 'NULL'; + $query_value[$query_value_index] .= 'NULL'; } else { - $query.= "'".$insert[$dbfield]."'"; + $query_value[$query_value_index] .= "'".$insert[$dbfield]."'"; } } - $query.=')'; + $query_value[$query_value_index] .= ')'; } - $query.= ' + + $query_end .= ' ;'; - pwg_query($query); + foreach ($query_value as $value) + { + $final_query = $query_begin.$value.$query_end; + pwg_query($final_query); + } } } diff --git a/include/config_default.inc.php b/include/config_default.inc.php index 8e6a190c9..f33047a73 100644 --- a/include/config_default.inc.php +++ b/include/config_default.inc.php @@ -664,4 +664,12 @@ $conf['filter_pages'] = array // Every plugin from 1.7 would be design to manage light_slideshow case. $conf['light_slideshow'] = true; +// +-----------------------------------------------------------------------+ +// | mysql | +// +-----------------------------------------------------------------------+ + +// $conf['max_allowed_packet'] indicates the max size in octets of MySql +// request. Used in mass_inserts() function. +$conf['max_allowed_packet'] = 1000000; + ?> |