mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-08-06 08:43:31 +02:00
arrayfromquery optimizations: move double if from inside loop to outside + use directly mysqli calls to avoid function call overhead for every row retrieved from db
git-svn-id: http://piwigo.org/svn/trunk@27336 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
@@ -92,7 +92,7 @@ if (script_basename() == 'picture')
|
||||
{
|
||||
// url compatibility with versions below 1.6
|
||||
if ( isset($_GET['image_id'])
|
||||
and isset($_GET['cat'])
|
||||
and isset($_GET['cat'])
|
||||
and is_numeric($_GET['cat']) )
|
||||
{
|
||||
$url = make_picture_url( array(
|
||||
@@ -102,7 +102,7 @@ if (script_basename() == 'picture')
|
||||
) );
|
||||
redirect($url);
|
||||
}
|
||||
|
||||
|
||||
$token = $tokens[$next_token];
|
||||
$next_token++;
|
||||
if ( is_numeric($token) )
|
||||
@@ -242,7 +242,7 @@ if ('categories' == $page['section'])
|
||||
if (isset($page['category']))
|
||||
{
|
||||
$page = array_merge(
|
||||
$page,
|
||||
$page,
|
||||
array(
|
||||
'comment' => trigger_event(
|
||||
'render_category_description',
|
||||
@@ -292,8 +292,8 @@ SELECT id
|
||||
),
|
||||
"\n AND"
|
||||
);
|
||||
|
||||
$subcat_ids = array_from_query($query, 'id');
|
||||
|
||||
$subcat_ids = query2array($query,null, 'id');
|
||||
$subcat_ids[] = $page['category']['id'];
|
||||
$where_sql = 'category_id IN ('.implode(',',$subcat_ids).')';
|
||||
// remove categories from forbidden because just checked above
|
||||
@@ -325,7 +325,7 @@ SELECT DISTINCT(image_id)
|
||||
'.$conf['order_by'].'
|
||||
;';
|
||||
|
||||
$page['items'] = array_from_query($query, 'image_id');
|
||||
$page['items'] = query2array($query,null, 'image_id');
|
||||
}
|
||||
}
|
||||
// special sections
|
||||
@@ -416,7 +416,7 @@ SELECT image_id
|
||||
$page = array_merge(
|
||||
$page,
|
||||
array(
|
||||
'items' => array_from_query($query, 'image_id'),
|
||||
'items' => query2array($query,null, 'image_id'),
|
||||
)
|
||||
);
|
||||
|
||||
@@ -463,7 +463,7 @@ SELECT DISTINCT(id)
|
||||
array(
|
||||
'title' => '<a href="'.duplicate_index_url(array('start'=>0)).'">'
|
||||
.l10n('Recent photos').'</a>',
|
||||
'items' => array_from_query($query, 'id'),
|
||||
'items' => query2array($query,null, 'id'),
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -486,7 +486,7 @@ SELECT DISTINCT(id)
|
||||
{
|
||||
$page['super_order_by'] = true;
|
||||
$conf['order_by'] = ' ORDER BY hit DESC, id DESC';
|
||||
|
||||
|
||||
$query = '
|
||||
SELECT DISTINCT(id)
|
||||
FROM '.IMAGES_TABLE.'
|
||||
@@ -502,7 +502,7 @@ SELECT DISTINCT(id)
|
||||
array(
|
||||
'title' => '<a href="'.duplicate_index_url(array('start'=>0)).'">'
|
||||
.$conf['top_number'].' '.l10n('Most visited').'</a>',
|
||||
'items' => array_from_query($query, 'id'),
|
||||
'items' => query2array($query,null, 'id'),
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -528,7 +528,7 @@ SELECT DISTINCT(id)
|
||||
array(
|
||||
'title' => '<a href="'.duplicate_index_url(array('start'=>0)).'">'
|
||||
.$conf['top_number'].' '.l10n('Best rated').'</a>',
|
||||
'items' => array_from_query($query, 'id'),
|
||||
'items' => query2array($query,null, 'id'),
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -551,7 +551,7 @@ SELECT DISTINCT(id)
|
||||
array(
|
||||
'title' => '<a href="'.duplicate_index_url(array('start'=>0)).'">'
|
||||
.l10n('Random photos').'</a>',
|
||||
'items' => array_from_query($query, 'id'),
|
||||
'items' => query2array($query,null, 'id'),
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -632,7 +632,7 @@ if ( 'categories'==$page['section'] and isset($page['category']) )
|
||||
if ($need_redirect)
|
||||
{
|
||||
$redirect_url = script_basename()=='picture' ? duplicate_picture_url() : duplicate_index_url();
|
||||
|
||||
|
||||
if (!headers_sent())
|
||||
{ // this is a permanent redirection
|
||||
set_status_header(301);
|
||||
|
||||
Reference in New Issue
Block a user