vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   recalculation picture counts (https://vborg.vbsupport.ru/showthread.php?t=229207)

sailnet 11-30-2009 10:57 PM

recalculation picture counts
 
I have an external program which runs outside of vb adding records to the pictures tables and it also updates the album, albumpicture and albumupdate tables.

it's working great except that vb is not recalculating the number of of pictures in the album (well - vb is not displaying the correct number of pictures in the album on it's screens). I've looked through the code and found the function which does this in class_dm_album.php but there does not appear to an update statement at the end of the function. so where is this information stored?

PHP Code:

     Rebuilds counts for an album
     
*
     */
    function 
rebuild_counts()
    {
        if (!
$this->fetch_field('albumid'))
        {
            return;
        }

        
$counts $this->registry->db->query_first("
            SELECT
                SUM(IF(picture.state = 'visible', 1, 0)) AS visible,
                SUM(IF(picture.state = 'moderation', 1, 0)) AS moderation,
                MAX(IF(picture.state = 'visible', albumpicture.dateline, 0)) AS lastpicturedate
            FROM " 
TABLE_PREFIX "albumpicture AS albumpicture
            INNER JOIN " 
TABLE_PREFIX "picture AS picture ON (albumpicture.pictureid = picture.pictureid)
            WHERE albumpicture.albumid = " 
$this->fetch_field('albumid') . "

        "
);

        
$this->set('visible'$counts['visible']);
        
$this->set('moderation'$counts['moderation']);
        
$this->set('lastpicturedate'$counts['lastpicturedate']);
    } 

so - how do I get the count of pictures in an album to get updated properly outside of vb?

thanks in advance.

I suppose I could take all of my code and move it inside of a vbulletin module (or at least create a new module and just run that module and attempt to figure out how this function is called, but that's clearly not my prerference.

thanks in advance for any help you can give or direction.

kh99 11-30-2009 11:21 PM

That class extends vB_DataManager, which means some of the functions are in class_dm.php.

I think you could probably do the query like it's done in the code above, then use the results to update the album table 'visible', 'moderation', and 'lastpicturedate' fields for that albumid using an UPDATE query.

sailnet 12-01-2009 02:46 AM

Quote:

Originally Posted by kh99 (Post 1923263)
That class extends vB_DataManager, which means some of the functions are in class_dm.php.

I think you could probably do the query like it's done in the code above, then use the results to update the album table 'visible', 'moderation', and 'lastpicturedate' fields for that albumid using an UPDATE query.

yes, but I already do that in my code. all tables are updated properly.

--------------- Added [DATE]1259672493[/DATE] at [TIME]1259672493[/TIME] ---------------

found it - fixed it.

cool


All times are GMT. The time now is 08:13 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01040 seconds
  • Memory Usage 1,728KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (3)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete