vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   How does the datastore system work? (https://vborg.vbsupport.ru/showthread.php?t=72146)

dwh 11-24-2004 08:59 PM

How does the datastore system work?
 
There are some aspects of vb that are not obvious. The datastore looks interesting. Can someone familiar with the code provide an overview of how it works?

Andreas 11-24-2004 09:12 PM

Well ... datastore is nothing mysterious.

The table holds serialized content of variables (mostly arrays).

If you want to read one of those you must include the key in $specialtemplates, init.php will then load the according rows from the table into $datastore
To get your stuff use $myarray = unserialize($datastore['mykey']);
To write your stuff call build_datastore('mykey', serialize($myarray)), this function is defined in functions_databuild.php.

That's it.

Natch 11-24-2004 09:32 PM

Nice succinct answer, KirbyDE :D well done mate...

Andreas 11-24-2004 09:35 PM

Thanks. I wanted to keep bandwidth usage low ^.^

Reeve of shinra 11-25-2004 05:06 AM

If it still calls from the DB, what are the real advantages of it and what would be a good example of where to use / not use it? =p

Andreas 11-25-2004 11:16 AM

Well the advantage is that you don't need an additional query, as init.php will load all required rows with just 1 query.
So it is easy to store custom data without having to modify existing queries or introduce new ones.
I'd suse this for data that needs to be read often/all the time, but is only being updated seldom (as you can see, datastore holds things like user record, smilies, bbcode, etc).

dwh 11-25-2004 08:06 PM

Thanks. What confused me is that I started by looking at the raw data. While it doesn't quite look encrypted, it has a:n or s:n but other times it just has numbers. I don't quite get what those a: or s: stand for?

Natch 11-25-2004 08:29 PM

a = array
s = string
and the numbers indicate how many characters are included to reconstruct the object ...

dwh 01-13-2005 07:59 AM

Quote:

Originally Posted by KirbyDE
To get your stuff use $myarray = unserialize($datastore['mykey']);
To write your stuff call build_datastore('mykey', serialize($myarray))

How would you store just a string instead of a whole array?
Then how would you call it back?

I tried

PHP Code:

$testvar="ted";
build_datastore('mytest'$testvar); 

Which successfully put "ted" into "mytest" in the datastore table. However to get it back I tried
PHP Code:

 $anothertestvar=$datastore[mytest]; 

as well as
PHP Code:

 $anothertestvar=$datastore[testvar]; 

and it didn't work.

dwh 01-13-2005 08:40 AM

After putting 'mytest' in specialtemplates before calling global.php,
$datastore['mytest'] worked.


All times are GMT. The time now is 04:45 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.01058 seconds
  • Memory Usage 1,731KB
  • 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
  • (3)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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