Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
  #1  
Old 01-06-2010, 06:27 PM
ageurtse ageurtse is offline
 
Join Date: Apr 2009
Location: almelo
Posts: 275
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default sql problem, limit is not working

i have a sql string wich should export data.

this is the original string as i have it in my php file.
when i run it you get the second output

only the first page display's the correct limmit, al other pages displays to much item's
what could be the problem.

at the bottom you could find my code.



first
PHP Code:
        $attachments $vbulletin->db->query_read("
            SELECT attachment.attachmentid, attachment.contentid, attachment.userid, post.postid, post.threadid, post.visible,thread.forumid,
            thread.title, thread.open
            FROM vb3_attachment as attachment 
            LEFT JOIN vb3_post AS post ON (post.postid = attachment.contentid)
            LEFT JOIN vb3_thread as thread on(post.threadid = thread.threadid)
            LEFT JOIN vb3_deletionlog AS deletionlog ON(attachment.contentid = deletionlog.primaryid AND type = 'post')
            WHERE attachment.userid = "
.$this->profile->userinfo['userid']. "
            AND (
            thread.forumid IN(0
$forumids)
            AND thread.visible = 1 
            AND post.visible = 1 
            AND deletionlog.primaryid IS NULL) ORDER BY attachment.attachmentid DESC LIMIT "
.$limitlower.","$limitupper.""); 

current string (page=4, with 16 items per page)
PHP Code:
SELECT attachment.attachmentidattachment.contentidattachment.useridpost.postidpost.threadidpost.visible,thread.forumidthread.titlethread.open FROM vb3_attachment as attachment LEFT JOIN vb3_post AS post ON (post.postid attachment.contentidLEFT JOIN vb3_thread as thread on(post.threadid thread.threadidLEFT JOIN vb3_deletionlog AS deletionlog ON(attachment.contentid deletionlog.primaryid AND type 'post'WHERE attachment.userid 8646 AND ( thread.forumid IN(0,5,111,112,113,114,115,116,16,236,243,200,204,231,48,242,131,144,142,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,191,177,178,179,180,181,182,183,184,185,186,187,188,189,190,192,193,197,3,10,129,44,25,18,26,21,224,34,17,22,202,20,23,24,90,7,46,11,8,218,248,43,74,36,118,221,223,222,225,39,96,88,227,226,30,32,82,201,103,241,247,230,199,105,55,94,101,121,38,86,244,245,45,228,95,246,109,47,229,195,53,33,100,27,117,31,203,234,140,37,51,240,29,4,13,35,42,14,50,12,40,206,98,210,208,205,209,214,212,207,211,213,216,215,217,78,83,85,92,106,108,107,75,77,6,15,238,235,237,239) AND thread.visible AND post.visible AND deletionlog.primaryid IS NULLORDER BY attachment.attachmentid DESC LIMIT 48,64 

php file which generate sql string and output to screen
PHP Code:
    function prepare_output($id ''$options = array())
    {
            
        global 
$maxcolum$maxrow$maxwidth$maxheight$page$vbulletin$attachmentinfo;

        
$colum 0;
        
$forumidsnull;
     
        foreach (
$vbulletin->userinfo['forumpermissions'] AS $vbulletin->foruminfo[forumid] => $perm)
        {
            if ((
$perm $vbulletin->bf_ugp_forumpermissions['canview']))
            {
                
$forumids .= ','.$vbulletin->foruminfo[forumid];
            }
        }    
      
        
$attachments $vbulletin->db->query_read("
            SELECT attachment.attachmentid, attachment.contentid, attachment.userid, post.postid, post.threadid, post.visible,thread.forumid,
            thread.title, thread.open
            FROM vb3_attachment as attachment 
            LEFT JOIN vb3_post AS post ON (post.postid = attachment.contentid)
            LEFT JOIN vb3_thread as thread on(post.threadid = thread.threadid)
            LEFT JOIN vb3_deletionlog AS deletionlog ON(attachment.contentid = deletionlog.primaryid AND type = 'post')
            WHERE attachment.userid = "
.$this->profile->userinfo['userid']. "
            AND (
            thread.forumid IN(0
$forumids)
            AND thread.visible = 1 
            AND post.visible = 1 
            AND deletionlog.primaryid IS NULL)"
);
            
        
$totalattachments $vbulletin->db->num_rows($attachments);            
      
        
$perpage = ($maxcolum $maxrow);
        
$totalpages ceil($totalattachments $perpage);


    
sanitize_pageresults($totalattachments$page$perpage100$perpage);  

    if (
$page 1)
{
    
$page 1;
}
else if (
$page $totalpages)
{
    
$page ceil(($totalattachments 1) / $perpage);
}
$limitlower = ($page 1) * $perpage;
$limitupper = ($page $perpage);  
    
        
$output .= $limitlower ." "$limitupper;
        
        
$test "SELECT attachment.attachmentid, attachment.contentid, attachment.userid, post.postid, post.threadid, post.visible,thread.forumid,
            thread.title, thread.open
            FROM vb3_attachment as attachment 
            LEFT JOIN vb3_post AS post ON (post.postid = attachment.contentid)
            LEFT JOIN vb3_thread as thread on(post.threadid = thread.threadid)
            LEFT JOIN vb3_deletionlog AS deletionlog ON(attachment.contentid = deletionlog.primaryid AND type = 'post')
            WHERE attachment.userid = "
.$this->profile->userinfo['userid']. "
            AND (
            thread.forumid IN(0
$forumids)
            AND thread.visible = 1 
            AND post.visible = 1 
            AND deletionlog.primaryid IS NULL) ORDER BY attachment.attachmentid DESC LIMIT "
.$limitlower.","$limitupper."";
            
        
$attachments $vbulletin->db->query_read("
            SELECT attachment.attachmentid, attachment.contentid, attachment.userid, post.postid, post.threadid, post.visible,thread.forumid,
            thread.title, thread.open
            FROM vb3_attachment as attachment 
            LEFT JOIN vb3_post AS post ON (post.postid = attachment.contentid)
            LEFT JOIN vb3_thread as thread on(post.threadid = thread.threadid)
            LEFT JOIN vb3_deletionlog AS deletionlog ON(attachment.contentid = deletionlog.primaryid AND type = 'post')
            WHERE attachment.userid = "
.$this->profile->userinfo['userid']. "
            AND (
            thread.forumid IN(0
$forumids)
            AND thread.visible = 1 
            AND post.visible = 1 
            AND deletionlog.primaryid IS NULL) ORDER BY attachment.attachmentid DESC LIMIT "
.$limitlower.","$limitupper."");      
      
$output .= "<br>".$test."<br>";      
      

$pagenav construct_page_nav(
    
$vbulletin->GPC['page'],
    
$perpage,
    
$totalattachments,
    
'member.php?' $this->profile->userinfo['userid']. "&tab=mymodification"// the pagenav-link
    
''// to pass a second portion or the pagenav-link, gets directly appended to above
    
''// to pass an anchor
    
''// SEO-Link for thread, forum, member... pages - make the pagenav-links seo'ed if you use the paginator on one of those
    
''// Array to pass linkinfo for SEO-Link-Method
    
''  // Array to pass additional Info for SEO-Link-Method
);  
      

    
$output .= $pagenav;
    
    
      
      
        
$output .= "<br>";
        
$output .= "<br>Totaal aantal bijlagen ".$totalattachments"<br>Huidige pagina : "$curentpage" van "$totalpages"
                    URL page : "
.$page."<br>
                    <table border=1>"
;
        
         
        while (
$post mysql_fetch_array($attachments))
        {
            if (
$colum == 0) {$output .= "<TR>";}
        
            
$attachinfo fetch_attachment_info($this->profile->userinfo['userid'],$post['attachmentid'], 1);
            if (
$attachinfo[2] != 1){
                
$prefix "width=".($maxwidth-25);} else 
                { 
$prefix "height=".($maxheight-25);}
                    
            
$output .= "<td width=".$maxwidth." height=".$maxheight."><center><a target=blank href=attachment.php?attachmentid=".$post['attachmentid'].">
                        <img border=0 src=attachment.php?attachmentid="
.$post['attachmentid']."&thumb=1 ".$prefix.">
                        </a><br>"
.($attachinfo[2]+1)." </center></td>" ;
        
            
$colum $colum 1;

            if (
$colum == $maxcolum){ 
                
$colum 0
                
$output .= "</tr><tr>";
                }
        }
        
$output .= "</table>";
        
$this->block_data['mymodification'] = $output;
    }

Reply With Quote
  #2  
Old 01-09-2010, 07:27 PM
ageurtse ageurtse is offline
 
Join Date: Apr 2009
Location: almelo
Posts: 275
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

solved, limit startvalue, max values (not end value)
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:52 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03989 seconds
  • Memory Usage 2,267KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (3)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (2)post_thanks_box
  • (2)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (2)post_thanks_postbit_info
  • (2)postbit
  • (2)postbit_onlinestatus
  • (2)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete