Member Log In
Site Navigation
Latest Modifications
- [vB 3.8.4] THX - Hack for VB. 3.8.4
By: bluedog - [vB 3.8.4] Cyb - Chatbox V.2.3
By: bluedog - [vB 4.0.x] PHPKD - Advanced Quick...
By: PHPKD - [vB 3.6.x] StopSpam
By: flappi282 - [vB 3.8.x] vBulletin Chat Addon for...
By: 123flashchat
Latest Template Mods
- [vB 4.0.x] Remove My Profile Link...
By: Ak Worm - [vB 3.8.x] Images DownloadBox...
By: cRs!MP - [vB 3.8.x] Adviertise Mod On Forum...
By: MG4 - [vB 3.8.4] Images PassWordBox...
By: cRs!MP - [vB 3.8.4] Footer Follow Ups
By: Ak Worm
Latest Styles
- [vB 4.0.x] 4.0.3 - VB4STYLE-TWEETA...
By: Belon - [vB 4.0.x] [4.0.3] vbdesigns.de...
By: Belon - [vB 3.8.4] CompletevB - Skylight
By: DreadKnight - [vB 3.8.3] [vB 3.8.4] Barcelona...
By: hoiquantinhoc.com - [vB 3.8.3] Natures Walk by vBSkin...
By: Chri5
Latest Graphics
- [vB ] [anim.]Team Ranks
By: cRs!MP - [vB ] Abstract Circles (3...
By: cRs!MP - [vB ] PlayStation Rank Images
By: cRs!MP - [vB 3.6.12] Heavy Stroked Button...
By: Shelley - [vB ] Minature Ranks.
By: Shelley
vBulletin Modifications »
General vBulletin Section »
vBulletin Modification Tutorials »
Cache System Explanation (datastore)
![]() |
| | #1 |
| |
Status: Offline I'm going to try and explain the datastore system used in vBulltin. This tutorial is based around users who are already familar with PHP and MySQL. What is Cache? I'll show you way using the datastore is a better solution for you and the users who will use your hacks. data1.gif Now everytime you add, edit, or delete your information, it will be changed in the database. Here is an example of the database tree. We have 3 rows of information. data2.gif PHP Code: Then you need to use the function called build_datastore(). This function requires the following. build_datastore(1, 2). #1 is the name of your datastore item, and number two is the serialize information to store. This function will create a new datastore item with the name and all your info. The serialize info will look like this... Code: a:3:{i:0;a:3:{s:2:"id";s:1:"1";s:4:"name";s:3:"Dog";s:5:"value";s:3:"Dog";}i:1;a:3:{s:2:"id";s:1:"2";s:4:"name";s:3:"Cat";s:5:"value";s:3:"Cat";}i:2;a:3:{s:2:"id";s:1:"3";s:4:"name";s:3:"Cow";s:5:"value";s:3:"Cow";}}
data3.gif Don't let the serialize data freak you out. You don't really NEED to read that data. Though I kinda like doing it, so I'll break it down alittle for you. Here is a tree of the serialize data. Code: a:3:{
i:0; a:3:{
s:2:"id";s:1:"1";
s:4:"name";s:3:"Dog";
s:5:"value";s:3:"Dog";
}
i:1; a:3:{
s:2:"id";s:1:"2";
s:4:"name";s:3:"Cat";
s:5:"value";s:3:"Cat";
}
i:2; a:3:{
s:2:"id";s:1:"3";
s:4:"name";s:3:"Cow";
s:5:"value";s:3:"Cow";
}
}
PHP Code: PHP Code: (ID: 1) (Title: Dog) (Value: Dog) (ID: 2) (Title: Cat) (Value: Cat) (ID: 3) (Title: Cow) (Value: Cow) What your doing is simple. The variable $vbulletin->dropmenu holds the information though it's still serialize. The reason why $vbulletin->dropmenu is the variable is because you need to tell vBulletin which datastore row to get. In this case it is dropmenu because remember we stored it in there like this: build_datastore('dropmenu', serialize($variable_array)); Now in order for vBulletin to know about that specific row, you need to add it to the $specialtemplates array. Example: PHP Code: So $vbulletin->dropmenu = unserialize($vbulletin->dropmenu); baiscly gets the serialize info and unserialize's it using the function called unserialize() Once that is finished you want to loop the info using a foreach() function. foreach ($vbulletin->dropmenu AS $dropmenu). Doing that is storing the array info into $dropmenu and you can get each one by using the following vaiables. $dropmenu['id'], $dropmenu['title'], and $dropmenu['value']. The reason why this is better is because vBulletin allready runs one global query to get all the datatore information. So instead of running a query everytime you want to get the drop down information, you just get it from the datastore and save that query. Some may think this is kinda extreme when you can just run a query, though as your site grows; you want to save as many queires as possiable. If your interested in saving queries and bandwidth. I would suggest taking a look at Trigunflames profile. He has released many hacks to help in these areas. ![]() Copyright ©2004-2006 vBHackers.com All Rights Reserved. This tutorial may not be redistributed in whole or significant part. Ken Iovino / Escalate Media |
|
| | #2 |
| |
Status: Offline Very nice tut =) |
|
| | #4 | |||||||||
Location: Israel Age: 29 ![]() |
Status: Offline yep, very nice tut indeed. :] Regards, Idan. * Support will only be given via forums ! * If this post solved/aided your problem, please click "mark as aid" / "mark as solution" as explained in here | |||||||||
|
| | #7 | ||||||||
| tgreer Guest
| @LiveWire: Thanks for this, but I have some questions. Q. I understand that the results of a SQL query must be
However, WHEN must this be done? Once? In global_start, for example? Should there be a conditional to see if the data is already in the datastore? I'm curious how the original data is synchronized with the datastore. Q. $specialtemplates kind of came out of the blue in your tutorial. What is the relationship between the datastore record and $specialtemplates? At what point would you add your datastore item/record to $specialtemplates? Q. You explain the datastore well enough, but not caching. There is the raw data in the database. There is serialized data in the datastore table, but isn't there also a datastore caching mechanism, so that information can be retrieved from a cache without going back to the datastore table itself? So, how can you get information from the cache vs. the datastore vs. a raw query? Or, is the datastore automatically cached, so any calls for datastore data come from the cache anyway? | ||||||||
|
| | #8 |
| |
Status: Offline Q. $specialtemplates kind of came out of the blue in your tutorial. What is the relationship between the datastore record and $specialtemplates? At what point would you add your datastore item/record to $specialtemplates? If I'm not mistaking, $specialtemplates gets the data from the datastore if its a custom datastore item. |
|
| | #9 | ||||||||
| tgreer Guest
| So, in terms of this tutorial... THIS: PHP Code: PHP Code: What does putting your datastore record name/id in $specialtemplates actually do? I have a suspicion that $vbulletin->dropmenu doesn't get data from the datastore at all, but rather from the datastore cache, and that adding $dropmenu to the $specialtemplates array makes sure that it IS cached. I'm not certain... anyone willing to correct/confirm this? | ||||||||
|
| | #10 |
| |
Status: Offline anytime you enter new information in your custom table, you have to get all the info from that table and update the datastore table with all the info. the specialtemplates array is the name of the row your datastore is stored in. When I get back from easter dinner I'll explain it better for you. :p |
|
![]() |
« [How-To] Use plugins to join default queries
|
[How-to] Correct the missing WOL location for the activity addon stats »
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Install system updated | Ken Iovino | Announcements | 7 | 11-17-2006 05:59 PM |
| [REQUEST] Rating System (Possibly by TouchingVirus or ShavedApe?) | figure004 | vBulletin Modification Requests | 4 | 05-22-2005 07:14 PM |
All times are GMT. The time now is 05:58 AM.
Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.































