Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 03-31-2008, 06:27 PM
rob30UK rob30UK is offline
 
Join Date: Oct 2005
Location: UK
Posts: 159
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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');
?>
True enough when the cron is fired the data is entered into the datastore which I can see via phpmyadmin.

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;
Nothing seems to work. Does anyone know the stupidly obvious thing that I am forgetting to do here?
Reply With Quote
  #2  
Old 03-31-2008, 06:37 PM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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;
Reply With Quote
  #3  
Old 03-31-2008, 07:30 PM
rob30UK rob30UK is offline
 
Join Date: Oct 2005
Location: UK
Posts: 159
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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);
?>
and in postbit_display_complete I run this code
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;
Nothing has come through - the datastore should be appended to the end of every post (I've tested that code also with a normal string.. eg. I can append hello to every post with $this->post['message'] .= "hello"

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.
Reply With Quote
  #4  
Old 03-31-2008, 07:35 PM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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']?
Reply With Quote
  #5  
Old 03-31-2008, 07:49 PM
rob30UK rob30UK is offline
 
Join Date: Oct 2005
Location: UK
Posts: 159
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #6  
Old 03-31-2008, 08:00 PM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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);
That is the install code query I run when setting up the hack. You would put glossary_links where I have statscache.

And here is the uninstall code I use:

Code:
 
DELETE FROM " . TABLE_PREFIX . "datastore WHERE title = 'statscache' LIMIT 1
Reply With Quote
  #7  
Old 03-31-2008, 08:15 PM
rob30UK rob30UK is offline
 
Join Date: Oct 2005
Location: UK
Posts: 159
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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....
Reply With Quote
  #8  
Old 03-31-2008, 09:19 PM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #9  
Old 04-01-2008, 07:13 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
$kwdStr="I will not show at the end of every post!";
build_datastore('glossary_links'serialize($kwdStr),1); 
Why are you serializing a string. Serializing is done on an array.
Reply With Quote
  #10  
Old 04-01-2008, 07:39 AM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I think he is trying to update the datastore there.
Reply With Quote
Reply


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:35 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.06008 seconds
  • Memory Usage 2,268KB
  • 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
  • (8)bbcode_code
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete