The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
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 ? |
#2
|
||||
|
||||
Quote:
ie build_datastore('my_datastore', serialize($myvalues)); Or did you just save it manually into the datastore? |
#3
|
||||
|
||||
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. |
#4
|
||||
|
||||
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 |
#5
|
|||
|
|||
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.
|
#6
|
||||
|
||||
The correct way would be to use this;
PHP Code:
Another way is to add PHP Code:
|
#7
|
|||
|
|||
Actually datastore->fetch is VERY BAD as per my bug report, which they wont fix, http://www.vbulletin.com/forum/bugs3...iew&bugid=1390
|
#8
|
|||
|
|||
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.
|
#9
|
||||
|
||||
Quote:
|
#10
|
|||
|
|||
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. |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|