- SQL query refactoring

- deletion of "mode" var in URL for searchs


git-svn-id: http://piwigo.org/svn/trunk@454 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
z0rglub 2004-07-26 20:42:48 +00:00
parent 16b2b85934
commit d119cf3344

View file

@ -54,13 +54,13 @@ if ( 0 )
} }
// retrieving the number of the picture in its category (in order) // retrieving the number of the picture in its category (in order)
$query = 'SELECT DISTINCT(id)'; $query = '
$query.= ' FROM '.IMAGES_TABLE; SELECT DISTINCT(id)
$query.= ' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic'; FROM '.IMAGES_TABLE.'
$query.= ' ON id = ic.image_id'; INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id
$query.= $page['where']; '.$page['where'].'
$query.= $conf['order_by']; '.$conf['order_by'].'
$query.= ';'; ;';
$result = mysql_query( $query ); $result = mysql_query( $query );
$page['num'] = 0; $page['num'] = 0;
$row = mysql_fetch_array( $result ); $row = mysql_fetch_array( $result );
@ -87,12 +87,13 @@ if ( $page['num'] == $page['cat_nb_images'] - 1 )
$next = 0; $next = 0;
} }
$query = 'SELECT *'; $query = '
$query.= ' FROM '.IMAGES_TABLE; SELECT *
$query.= ' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic'; FROM '.IMAGES_TABLE.'
$query.= ' ON id=ic.image_id'; INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id=ic.image_id
$query.= $page['where']; '.$page['where'].'
$query.= $conf['order_by']; '.$conf['order_by'].'
';
if ( $prev < 0 ) if ( $prev < 0 )
{ {
@ -142,7 +143,6 @@ for ( $i = 0; $i < $nb_row; $i++ )
if ( $page['cat'] == 'search' ) if ( $page['cat'] == 'search' )
{ {
$picture[$j]['url'].= '&amp;search='.$_GET['search']; $picture[$j]['url'].= '&amp;search='.$_GET['search'];
$picture[$j]['url'].= '&amp;mode='.$_GET['mode'];
} }
} }
@ -150,7 +150,7 @@ $url_home = PHPWG_ROOT_PATH.'category.php?cat='.$page['cat'].'&amp;';
$url_home.= 'num='.$page['num']; $url_home.= 'num='.$page['num'];
if ( $page['cat'] == 'search' ) if ( $page['cat'] == 'search' )
{ {
$url_home.= "&amp;search=".$_GET['search'].'&amp;mode='.$_GET['mode']; $url_home.= "&amp;search=".$_GET['search'];
} }
$url_admin = PHPWG_ROOT_PATH.'admin.php?page=picture_modify'; $url_admin = PHPWG_ROOT_PATH.'admin.php?page=picture_modify';
@ -530,7 +530,7 @@ if ( $conf['show_comments'] )
$url = PHPWG_ROOT_PATH.'picture.php?cat='.$page['cat'].'&amp;image_id='.$_GET['image_id']; $url = PHPWG_ROOT_PATH.'picture.php?cat='.$page['cat'].'&amp;image_id='.$_GET['image_id'];
if ( $page['cat'] == 'search' ) if ( $page['cat'] == 'search' )
{ {
$url.= '&amp;search='.$_GET['search'].'&amp;mode='.$_GET['mode']; $url.= '&amp;search='.$_GET['search'];
} }
if( !isset( $_GET['start'] ) if( !isset( $_GET['start'] )
or !is_numeric( $_GET['start'] ) or !is_numeric( $_GET['start'] )