mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-07-19 16:13:00 +02:00
Issue : 137
git-svn-id: http://piwigo.org/svn/trunk@1790 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
+29
-28
@@ -521,60 +521,61 @@ 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_begin = '
|
||||
INSERT INTO '.$table_name.'
|
||||
('.implode(',', $dbfields).')
|
||||
VALUES';
|
||||
|
||||
$first = true;
|
||||
$query_value = '';
|
||||
|
||||
|
||||
$query = 'SHOW VARIABLES where variable_name = \'max_allowed_packet\';';
|
||||
list(, $packet_size) = mysql_fetch_row(pwg_query($query));
|
||||
$packet_size = $packet_size - 2000; // The last list of values MUST not exceed 2000 character
|
||||
|
||||
foreach ($datas as $insert)
|
||||
{
|
||||
if (strlen($query) >= $packet_size)
|
||||
{
|
||||
$query .= '
|
||||
;';
|
||||
pwg_query($query);
|
||||
$first = true;
|
||||
}
|
||||
|
||||
if ($first)
|
||||
{
|
||||
$query = '
|
||||
INSERT INTO '.$table_name.'
|
||||
('.implode(',', $dbfields).')
|
||||
VALUES';
|
||||
$first = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (strlen($query_value) >= $conf['max_allowed_packet'])
|
||||
{
|
||||
pwg_query( $query_begin.$query_value );
|
||||
$query_value = '';
|
||||
}
|
||||
else
|
||||
{
|
||||
$query_value .= ',';
|
||||
}
|
||||
$query .= '
|
||||
, ';
|
||||
}
|
||||
|
||||
$query_value .= '
|
||||
(';
|
||||
|
||||
|
||||
$query .= '(';
|
||||
foreach ($dbfields as $field_id => $dbfield)
|
||||
{
|
||||
if ($field_id > 0)
|
||||
{
|
||||
$query_value .= ',';
|
||||
$query .= ',';
|
||||
}
|
||||
|
||||
if (!isset($insert[$dbfield]) or $insert[$dbfield] === '')
|
||||
{
|
||||
$query_value .= 'NULL';
|
||||
$query .= 'NULL';
|
||||
}
|
||||
else
|
||||
{
|
||||
$query_value .= "'".$insert[$dbfield]."'";
|
||||
$query .= "'".$insert[$dbfield]."'";
|
||||
}
|
||||
}
|
||||
$query_value .= ')';
|
||||
$query .= ')';
|
||||
}
|
||||
pwg_query($query_begin.$query_value);
|
||||
|
||||
$query .= '
|
||||
;';
|
||||
pwg_query($query);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -677,12 +677,4 @@ $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;
|
||||
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user