The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Can write to datastore, but not retrieve.
I made a cron which writes to the datastore, but I cannot retrieve it in any plugins.
Just to be sure Im not going mad I changed my cron code to a very very simple Code:
<?php build_datastore('glossary_links', 'thisistestdata'); ?> Now I have tried every which way that I can to retrieve this data and have tried several hook locations but no matter what I do I cannot retrieve the data from out the datastore again. I've tried Code:
global $vbulletin; $glossary_links = $vbulletin->glossary_links; |
#2
|
||||
|
||||
Use this to build the datastore:
Code:
build_datastore('glossary_links', serialize($glossary_links),1); and this to fetch it: Code:
if (method_exists($vbulletin->datastore,'do_fetch')) { // Datastore extension exists, use it $vbulletin->datastore->do_fetch('glossary_links',$errors); if ($errors[0]) { // Fetch failed, use original datastore $vbulletin->datastore->do_db_fetch("'glossary_links'"); } } else { // No extension, use original datastore $vbulletin->datastore->do_db_fetch("'glossary_links'"); } $glossary_links = $vbulletin->glossary_links; |
#3
|
|||
|
|||
Hi Boofo!!
Thank you very very much for your help this has been driving me insane for hours. I still cant get it going though... In my test, this cron builds the datastore: Code:
<?php $kwdStr="I will not show at the end of every post!"; build_datastore('glossary_links', serialize($kwdStr),1); ?> Code:
if (method_exists($vbulletin->datastore,'do_fetch')) { // Datastore extension exists, use it $vbulletin->datastore->do_fetch('glossary_links',$errors); if ($errors[0]) { // Fetch failed, use original datastore $vbulletin->datastore->do_db_fetch("'glossary_links'"); } } else { // No extension, use original datastore $vbulletin->datastore->do_db_fetch("'glossary_links'"); } $glossary_links = $vbulletin->glossary_links; $this->post['message'] .= $glossary_links; Am I doing something wrong when I try and output the data? It's a plain string I am storing in the datastore, not an array or anything. |
#4
|
||||
|
||||
Why not just do a profile field for the info?
--------------- Added [DATE]1206995932[/DATE] at [TIME]1206995932[/TIME] --------------- have you truied using $glossary_links instead of $this->post['message']? |
#5
|
|||
|
|||
hah well, I'm using it for more than just this, I just broke it right down above to try and get any form of datastore working.
No, what I am really doing is using the extra thread fields lite hack to add an extra field to threads in the glossary forum. The extra field takes a comma seperated list of keywords. The keywords, or key phrases will then get automatically linked back to the thread whenever they occur in any post on the site. i use the extra thread field approach because our staff can easy add the linked terms when creating glossary threads. My cron basically goes along once a day and caches the 'keywords' and 'threadid' for all threads (where that extra field isnt blank) Everything up to this point works but I cant carry on because even though the data is in the database in the datastore table I cannot retrieve it no matter what I do. The alternative is to do a database SELECT from threads table where keywords (field1) != '' I can of course code around not having a datastore, but the fact is we do have a datastore.... but it seems very difficult to use for 'custom' data. I still cant get it going. this:- $vbulletin->mydatastoreitem is it returned in the same variable type 'as entered' for instance if I pass a string to the datastore, will it return a string? Or does it always return an array, or something else? Sorry if I am seeming a little thick, PHP isnt my usual sweetstuff. |
#6
|
||||
|
||||
I'm new at the datastore stuff myself so I know what you are going through. I did a hack for my site that uses the datastore to retrieve top poster, top thread starter, etc. The code I gave you is from that. Paul M and cheesgrits helped me get to the point of it working like it should.
Here is how I do it: glossary_links[datastoreitem] and it display the piece of info from the datastore I have entered into it. Here is how I set it up to add the info to the db. Code:
$options = array( 'arcadegames' => 1, 'arcadecats' => 1, 'getthreadviews' => 1, 'topposter' => 1, 'topposterid' => 1, 'toppostercount' => 1, 'topposterpercent' => 1, 'topstarter' => 1, 'topstarterid' => 1, 'topstartercount' => 1, 'topthreadspercent' => 1, 'getfileviewsun' => 1, 'getfileviewsid' => 1, 'getfileviews' => 1, 'ref2' => 1, 'topreferrerid' => 1, 'ref' => 1, 'lastupdate' => 1, ); build_datastore('statscache', serialize($options),1); And here is the uninstall code I use: Code:
DELETE FROM " . TABLE_PREFIX . "datastore WHERE title = 'statscache' LIMIT 1 |
#7
|
|||
|
|||
Ok, thats very helpful boofo.....
Could I see an example of how you are reading these items back from the datastore? That would appear to be where i'm falling down.... |
#8
|
||||
|
||||
The code I gave you (if (method_exists($vbulletin->datastore,'do_fetch'))) is what I use to pull the info for display. I put that at the very beginning of my code and then set up the variables to be added to the datastore at a given time (every 15 minutes for my hack). If you have IM, PM me and I can send you the hack so you can look at how I did it if that will help you at all.
|
#9
|
|||
|
|||
PHP Code:
|
#10
|
||||
|
||||
I think he is trying to update the datastore there.
|
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|