mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-07-06 01:42:29 +02:00
- images.path column added to reduce database access
- function mass_inserts moved from admin/remote_sites.php to admin/include/function.php - function mass_inserts used in admin/update.php git-svn-id: http://piwigo.org/svn/trunk@606 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
@@ -784,4 +784,51 @@ function my_error($header, $echo = true)
|
||||
return $error;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* inserts multiple lines in a table
|
||||
*
|
||||
* @param string table_name
|
||||
* @param array dbields
|
||||
* @param array inserts
|
||||
* @return void
|
||||
*/
|
||||
function mass_inserts($table_name, $dbfields, $inserts)
|
||||
{
|
||||
// inserts all found categories
|
||||
$query = '
|
||||
INSERT INTO '.$table_name.'
|
||||
('.implode(',', $dbfields).')
|
||||
VALUES';
|
||||
foreach ($inserts as $insert_id => $insert)
|
||||
{
|
||||
$query.= '
|
||||
';
|
||||
if ($insert_id > 0)
|
||||
{
|
||||
$query.= ',';
|
||||
}
|
||||
$query.= '(';
|
||||
foreach ($dbfields as $field_id => $dbfield)
|
||||
{
|
||||
if ($field_id > 0)
|
||||
{
|
||||
$query.= ',';
|
||||
}
|
||||
|
||||
if (!isset($insert[$dbfield]) or $insert[$dbfield] == '')
|
||||
{
|
||||
$query.= 'NULL';
|
||||
}
|
||||
else
|
||||
{
|
||||
$query.= "'".$insert[$dbfield]."'";
|
||||
}
|
||||
}
|
||||
$query.=')';
|
||||
}
|
||||
$query.= '
|
||||
;';
|
||||
pwg_query($query);
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -319,9 +319,7 @@ SELECT *
|
||||
$result = pwg_query($query);
|
||||
while ($row = mysql_fetch_array($result))
|
||||
{
|
||||
$thumbnail_url = get_thumbnail_src($row['file'],
|
||||
$row['storage_category_id'],
|
||||
@$row['tn_ext']);
|
||||
$thumbnail_url = get_thumbnail_src($row['path'], @$row['tn_ext']);
|
||||
|
||||
$template->assign_block_vars(
|
||||
'picture',
|
||||
|
||||
@@ -199,9 +199,7 @@ else
|
||||
$current_category = get_cat_info($row['storage_category_id']);
|
||||
$dir_path = get_cat_display_name($current_category['name'], '->', '');
|
||||
|
||||
$thumbnail_url = get_thumbnail_src($row['file'],
|
||||
$row['storage_category_id'],
|
||||
@$row['tn_ext']);
|
||||
$thumbnail_url = get_thumbnail_src($row['path'], @$row['tn_ext']);
|
||||
|
||||
$url_img = PHPWG_ROOT_PATH.'picture.php?image_id='.$_GET['image_id'];
|
||||
$url_img .= '&cat='.$row['storage_category_id'];
|
||||
|
||||
+3
-49
@@ -111,53 +111,6 @@ SELECT id,dir
|
||||
return $database_dirs;
|
||||
}
|
||||
|
||||
/**
|
||||
* inserts multiple lines in a table
|
||||
*
|
||||
* @param string table_name
|
||||
* @param array dbields
|
||||
* @param array inserts
|
||||
* @return void
|
||||
*/
|
||||
function mass_inserts($table_name, $dbfields, $inserts)
|
||||
{
|
||||
// inserts all found categories
|
||||
$query = '
|
||||
INSERT INTO '.$table_name.'
|
||||
('.implode(',', $dbfields).')
|
||||
VALUES';
|
||||
foreach ($inserts as $insert_id => $insert)
|
||||
{
|
||||
$query.= '
|
||||
';
|
||||
if ($insert_id > 0)
|
||||
{
|
||||
$query.= ',';
|
||||
}
|
||||
$query.= '(';
|
||||
foreach ($dbfields as $field_id => $dbfield)
|
||||
{
|
||||
if ($field_id > 0)
|
||||
{
|
||||
$query.= ',';
|
||||
}
|
||||
|
||||
if (!isset($insert[$dbfield]) or $insert[$dbfield] == '')
|
||||
{
|
||||
$query.= 'NULL';
|
||||
}
|
||||
else
|
||||
{
|
||||
$query.= "'".$insert[$dbfield]."'";
|
||||
}
|
||||
}
|
||||
$query.=')';
|
||||
}
|
||||
$query.= '
|
||||
;';
|
||||
pwg_query($query);
|
||||
}
|
||||
|
||||
/**
|
||||
* read $listing_file and update a remote site according to its id
|
||||
*
|
||||
@@ -418,7 +371,8 @@ SELECT file
|
||||
'author',
|
||||
'keywords',
|
||||
'name',
|
||||
'comment');
|
||||
'comment',
|
||||
'path');
|
||||
foreach ($optional_atts as $att)
|
||||
{
|
||||
if (getAttribute($xml_element, $att) != '')
|
||||
@@ -434,7 +388,7 @@ SELECT file
|
||||
{
|
||||
$dbfields = array('file','storage_category_id','date_available','tn_ext',
|
||||
'filesize','width','height','date_creation','author',
|
||||
'keywords','name','comment');
|
||||
'keywords','name','comment','path');
|
||||
mass_inserts(IMAGES_TABLE, $dbfields, $inserts);
|
||||
$counts{'new_elements'}+= count($inserts);
|
||||
|
||||
|
||||
+10
-43
@@ -31,7 +31,7 @@ if( !defined("PHPWG_ROOT_PATH") )
|
||||
}
|
||||
include_once( PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php');
|
||||
|
||||
define('CURRENT_DATE', "'".date('Y-m-d')."'");
|
||||
define('CURRENT_DATE', date('Y-m-d'));
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | functions |
|
||||
// +-----------------------------------------------------------------------+
|
||||
@@ -407,10 +407,11 @@ SELECT file
|
||||
if ($tn_ext != '')
|
||||
{
|
||||
$insert = array();
|
||||
$insert['file'] = "'".$unregistered_element."'";
|
||||
$insert['file'] = $unregistered_element;
|
||||
$insert['storage_category_id'] = $category_id;
|
||||
$insert['date_available'] = CURRENT_DATE;
|
||||
$insert['tn_ext'] = "'".$tn_ext."'";
|
||||
$insert['tn_ext'] = $tn_ext;
|
||||
$insert['path'] = $dir.$unregistered_element;
|
||||
|
||||
$counts['new_elements']++;
|
||||
array_push($inserts, $insert);
|
||||
@@ -446,16 +447,17 @@ SELECT file
|
||||
}
|
||||
|
||||
$insert = array();
|
||||
$insert['file'] = "'".$unregistered_element."'";
|
||||
$insert['file'] = $unregistered_element;
|
||||
$insert['path'] = $dir.$unregistered_element;
|
||||
$insert['storage_category_id'] = $category_id;
|
||||
$insert['date_available'] = CURRENT_DATE;
|
||||
if ( $tn_ext != '' )
|
||||
{
|
||||
$insert['tn_ext'] = "'".$tn_ext."'";
|
||||
$insert['tn_ext'] = $tn_ext;
|
||||
}
|
||||
if ( $representative_ext != '' )
|
||||
{
|
||||
$insert['representative_ext'] = "'".$representative_ext."'";
|
||||
$insert['representative_ext'] = $representative_ext;
|
||||
}
|
||||
|
||||
$counts['new_elements']++;
|
||||
@@ -475,44 +477,9 @@ SELECT file
|
||||
// inserts all found pictures
|
||||
$dbfields = array(
|
||||
'file','storage_category_id','date_available','tn_ext'
|
||||
,'representative_ext'
|
||||
,'representative_ext','path'
|
||||
);
|
||||
$query = '
|
||||
INSERT INTO '.IMAGES_TABLE.'
|
||||
('.implode(',', $dbfields).')
|
||||
VALUES
|
||||
';
|
||||
foreach ($inserts as $insert_id => $insert)
|
||||
{
|
||||
$query.= '
|
||||
';
|
||||
if ($insert_id > 0)
|
||||
{
|
||||
$query.= ',';
|
||||
}
|
||||
$query.= '(';
|
||||
foreach ($dbfields as $field_id => $dbfield)
|
||||
{
|
||||
if ($field_id > 0)
|
||||
{
|
||||
$query.= ',';
|
||||
}
|
||||
|
||||
if (!isset($insert[$dbfield]) or $insert[$dbfield] == '')
|
||||
{
|
||||
$query.= 'NULL';
|
||||
}
|
||||
else
|
||||
{
|
||||
$query.= $insert[$dbfield];
|
||||
}
|
||||
}
|
||||
$query.=')';
|
||||
}
|
||||
$query.= '
|
||||
;';
|
||||
|
||||
pwg_query($query);
|
||||
mass_inserts(IMAGES_TABLE, $dbfields, $inserts);
|
||||
|
||||
// what are the ids of the pictures in the $category_id ?
|
||||
$ids = array();
|
||||
|
||||
Reference in New Issue
Block a user