View Full Version : trouble accessing datastore
VodkaFish
01-29-2008, 04:51 AM
Recently I moved my site to new servers. I have the latest versino of vb 3.6.
In the process, I also upgraded from PHP4 to PHP5, and also upgraded to MySQL 5.0.x.
In general, things are going well.
However, I cannot access the datastore like I used to.
I would set something like this:
build_datastore('mystuff', $parsing_cache, 1);
I would then access it like this:
$myvariable = $vbulletin->datastore->registry->mystuff;
However, $vbulletin->datastore->registry->mystuff is empty (and I checked with empty() ).
I look inside my db. mystuff is in the datastore table. The info looks correct.
What can I look for or tweak to access mystuff?
Opserty
01-29-2008, 06:27 AM
First your need to fetch it from the database, you can do this by creating a new Plugin with Hook Location init_startup.
Then for the PHP code you have:
// Notice the single quotes inside the double quotes
// These are required so don't remove them
$datastore_fetch[] = "'mystuff'"';
Then to access your data later on in the script you can use, $vbulletin->mystuff
An alternative method is just to fetch the item when you need it, using this piece of PHP:
$vbulletin->datastore->do_db_fetch("'mystuff'");
Again your data should be available through: $vbulletin->mystuff .
I prefer the first method as it means that if I'm fetching more then one thing from the datastore, they are all fetched in a single query as opposed to single queries dotted around the place.
VodkaFish
01-29-2008, 02:03 PM
Hi Opserty, thanks for the response.
Unfortunately, I still can't access what I'm trying to get (with either method). Somehow it's blank.
It's very puzzling. I can see the build_datastore is working, as it's in the db. I'm just not sure why I can't pull it from there.
Opserty
01-29-2008, 05:14 PM
Try running this in a plugin like global_start or forumhome_start:
$vbulletin->datastore->do_db_fetch("'mystuff'");
var_dump($vbulletin->mystuff);
echo '-------------------------------------------------';
$dataitems = $db->query_first("
SELECT *
FROM " . TABLE_PREFIX . "datastore
WHERE title = 'mystuff'
");
var_dump($dataitems);
What do you get outputted? (near the top of the page, view the source to get the proper formatting)
VodkaFish
01-29-2008, 05:47 PM
Interesting results:
NULL -------------------------------------------------array(3) { ["title"]=> string(15) "mystuff" ["data"]=> string(192718)
Then it continues with a good amount of data.
Opserty
01-29-2008, 06:02 PM
Hmm so it is fetching it then, you can remove the code I posted in my previous post. The only place I'm guessing the error could lie is when the data is unserialize()'d. Maybe the data has been somehow changed? Not sure how or why.
$parsing_cache has been serialize()'d hasn't it?
Try this:
if($vbulletin->datastore->do_db_fetch("'mystuff'"))
{
echo 'YEY!';
}
else
{
echo 'BOO!';
}
What do you get outputted? (Yey or Boo?)
VodkaFish
01-29-2008, 07:16 PM
Ha, that's exactly what I did at first.
It was "BOO!"
(I did nuffin/sumpin)
It's just odd that I can't access it. Is there any way I can clear all caches safely?
--------------- Added 1201643105 at 1201643105 ---------------
I tried renaming mystuff to somethingstuff and it had no effect (just seeing if I could clear some cache that way).
VodkaFish
01-31-2008, 12:25 AM
An update to my situation:
var_dump($vbulletin->mystuff);
Nothing happens.
$lots = $vbulletin->datastore->do_db_fetch("'mystuff'");
echo $lots;
Nothing happens.
$lots = $vbulletin->datastore->do_db_fetch("'mystuff'");
var_dump($vbulletin->mystuff);
That will give me the data I want in a test file. The custom mod I use that code in still isn't working, but that could be from another part of it.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.