Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
  #1  
Old 12-22-2005, 02:02 PM
deathemperor's Avatar
deathemperor deathemperor is offline
 
Join Date: Jul 2003
Location: HOL
Posts: 1,270
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Get value from datastore.

I defined and add 2 new datastores, I successfully added it into the datastore table (totalthreads and totalposts) now I try using

$totalthreads1 = vb_number_format(unserialize($datastorecache['totalthreads']));
$totalposts1 = vb_number_format(unserialize($datastorecache['totalposts']));

to get the value back but I somehow can't, anyone knows a way ?
Reply With Quote
  #2  
Old 12-22-2005, 02:05 PM
The Geek's Avatar
The Geek The Geek is offline
 
Join Date: Sep 2003
Location: Behind you
Posts: 2,779
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by deathemperor
I defined and add 2 new datastores, I successfully added it into the datastore table (totalthreads and totalposts) now I try using


$totalthreads1 = vb_number_format(unserialize($datastorecache['totalthreads']));
$totalposts1 = vb_number_format(unserialize($datastorecache['totalposts']));

to get the value back but I somehow can't, anyone knows a way ?
How did you save it to that datastore?

ie

build_datastore('my_datastore', serialize($myvalues));

Or did you just save it manually into the datastore?
Reply With Quote
  #3  
Old 12-22-2005, 02:29 PM
deathemperor's Avatar
deathemperor deathemperor is offline
 
Join Date: Jul 2003
Location: HOL
Posts: 1,270
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

of course I use build_datastore(), tried both ways:

$vbulletin->total['totalposts'] = $totalposts;
$vbulletin->total['totalthreads'] = $totalthreads;
build_datastore('total', serialize($vbulletin->total));

and

build_datastore('total', serialize($totalposts));
build_datastore('total', serialize($totalthreads));

the first one, I can get the value right after I use build_datastore, but I can't get it anywhere else. with the 2nd I have no idea how to get it

well I made it.

I borrow one datastore: maxloggedin and add 2 new value totalposts and totalthreads.

I wonder if there is a way to define a brand new datastore.
Reply With Quote
  #4  
Old 12-22-2005, 03:34 PM
The Geek's Avatar
The Geek The Geek is offline
 
Join Date: Sep 2003
Location: Behind you
Posts: 2,779
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You did, its called 'total'.
However the current problem with the datastore and the hook system is that you need to tell vB which 'datastores' you want caching. The problem being that you CANT do this without file edits as all hooks come AFTER the datastore is created.
Your only solution is to do what you did (hijack another 'datastore' that is cached by default) or manually query the datastore:

$myds = $db->query_read("SELECT data FROM " . TABLE_PREFIX . "datastore WHERE title ='mydatastore'");

$mydatastore = unserialize($myds['data']);

Bit of a bugger really
Reply With Quote
  #5  
Old 12-22-2005, 08:22 PM
merk merk is offline
 
Join Date: Nov 2001
Location: Canberra, Australia
Posts: 601
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yeh, theres no way to manually retrieve a datastore item without adding it to the $specialtemplates array (which has to be done at code time, cant be done at runtime) without doing a query.
Reply With Quote
  #6  
Old 12-22-2005, 08:42 PM
Paul M's Avatar
Paul M Paul M is offline
 
Join Date: Sep 2004
Location: Nottingham, UK
Posts: 23,748
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The correct way would be to use this;

PHP Code:
$vbulletin->datastore->fetch(array('totalposts''totalthreads')); 
As previously stated, this will add a query;


Another way is to add

PHP Code:
$specialtemplates[]='totalposts';
$specialtemplates[]='totalthreads'
To the bottom of your config.php file.
Reply With Quote
  #7  
Old 12-22-2005, 09:00 PM
merk merk is offline
 
Join Date: Nov 2001
Location: Canberra, Australia
Posts: 601
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Actually datastore->fetch is VERY BAD as per my bug report, which they wont fix, http://www.vbulletin.com/forum/bugs3...iew&bugid=1390
Reply With Quote
  #8  
Old 12-23-2005, 05:20 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Until a better solution comes up, in my plugins i simply check if the datastoreitem is already loaded, if not just use 1 simple query to retrieve it and add it to the datastore yourself. This will require max. 1 very simple query that will add hardly any processing time.
Reply With Quote
  #9  
Old 12-23-2005, 05:28 AM
Paul M's Avatar
Paul M Paul M is offline
 
Join Date: Sep 2004
Location: Nottingham, UK
Posts: 23,748
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by merk
Actually datastore->fetch is VERY BAD as per my bug report, which they wont fix, http://www.vbulletin.com/forum/bugs3...iew&bugid=1390
If it's in the init startup hook then I doubt any default items have been changed.
Reply With Quote
  #10  
Old 12-23-2005, 05:55 AM
merk merk is offline
 
Join Date: Nov 2001
Location: Canberra, Australia
Posts: 601
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Not all my datastore items are retrieved from there, though you shouldnt rely on that

I just made a function to do it for me that currently calls a query just like Marco said above.
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 02:51 PM.


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.04654 seconds
  • Memory Usage 2,253KB
  • Queries Executed 13 (?)
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
  • (2)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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_postinfo_query
  • fetch_postinfo
  • 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