[geeklog-cvs] geeklog-1.3/public_html lib-common.php,1.316,1.317
vinny at iowaoutdoors.org
vinny at iowaoutdoors.org
Fri Apr 30 19:36:16 EDT 2004
Update of /var/cvs/geeklog-1.3/public_html
In directory www:/tmp/cvs-serv28671/d
Modified Files:
lib-common.php
Log Message:
Reduced queries in COM_showTopics to improve performance.
Index: lib-common.php
===================================================================
RCS file: /var/cvs/geeklog-1.3/public_html/lib-common.php,v
retrieving revision 1.316
retrieving revision 1.317
diff -C2 -d -r1.316 -r1.317
*** lib-common.php 28 Apr 2004 03:21:39 -0000 1.316
--- lib-common.php 30 Apr 2004 23:36:12 -0000 1.317
***************
*** 1906,1910 ****
$page, $newstories;
! $sql = "SELECT tid,topic,owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon FROM {$_TABLES['topics']}";
if( $_USER['uid'] > 1 ) {
$tids = DB_getItem( $_TABLES['userindex'], 'tids',
--- 1906,1910 ----
$page, $newstories;
! $sql = "SELECT tid, topic FROM {$_TABLES['topics']}";
if( $_USER['uid'] > 1 ) {
$tids = DB_getItem( $_TABLES['userindex'], 'tids',
***************
*** 1932,1936 ****
}
$result = DB_query( $sql );
- $nrows = DB_numRows( $result );
$retval = '';
--- 1932,1935 ----
***************
*** 1968,1975 ****
}
! for( $i = 0; $i < $nrows; $i++ )
! {
! $A = DB_fetchArray( $result );
$sections->set_var( 'option_url', $_CONF['site_url']
. '/index.php?topic=' . $A['tid'] );
--- 1967,1992 ----
}
! if( $_CONF['showstorycount'] ) {
! $sql = "SELECT tid, count(*) AS count FROM {$_TABLES['stories']} "
! . 'WHERE (draft_flag = 0) AND (date <= NOW()) '
! . COM_getPermSQL( 'AND' )
! . ' GROUP BY tid';
! $rcount = DB_query($sql);
! while ( $C = DB_fetchArray($rcount) ) {
! $storycount[$C['tid']] = $C['count'];
! }
! }
!
! if( $_CONF['showsubmissioncount'] ) {
! $sql = "SELECT tid, count(*) AS count FROM {$_TABLES['storysubmission']} "
! . ' GROUP BY tid';
! $rcount = DB_query($sql);
! while ( $C = DB_fetchArray($rcount) ) {
! $submissioncount[$C['tid']] = $C['count'];
! }
! }
+ while ( $A = DB_fetchArray( $result ) )
+ {
$sections->set_var( 'option_url', $_CONF['site_url']
. '/index.php?topic=' . $A['tid'] );
***************
*** 1977,1981 ****
$countstring = '';
! if( $_CONF['showstorycount'] + $_CONF['showsubmissioncount'] > 0 )
{
$countstring .= '(';
--- 1994,1998 ----
$countstring = '';
! if( $_CONF['showstorycount'] || $_CONF['showsubmissioncount'] )
{
$countstring .= '(';
***************
*** 1983,1989 ****
if( $_CONF['showstorycount'] )
{
! $rcount = DB_query( "SELECT count(*) AS count FROM {$_TABLES['stories']} WHERE (draft_flag = 0) AND (date <= NOW()) AND (tid = '{$A['tid']}')" . COM_getPermSQL( 'AND' ));
! $T = DB_fetchArray( $rcount );
! $countstring .= $T['count'];
}
--- 2000,2008 ----
if( $_CONF['showstorycount'] )
{
! if ( empty( $storycount[$A['tid']] ) ) {
! $countstring .= 0;
! } else {
! $countstring .= $storycount[$A['tid']];
! }
}
***************
*** 1994,1999 ****
$countstring .= '/';
}
! $countstring .= DB_count( $_TABLES['storysubmission'],
! 'tid', $A['tid'] );
}
--- 2013,2021 ----
$countstring .= '/';
}
! if ( empty( $submissioncount[$A['tid']] ) ) {
! $countstring .= 0;
! } else {
! $countstring .= $submissioncount[$A['tid']];
! }
}
More information about the geeklog-cvs
mailing list