vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   [how-to] Cache some table (https://vborg.vbsupport.ru/showthread.php?t=107023)

Milad 02-03-2006 12:33 AM

[how-to] Cache some table
 
How to cache a table and insert it into datastore table or in datastor file?

like forumcache

thanks in advance

Nullifi3d 02-03-2006 01:22 AM

Are you asking how to store a table's fields in a php variable? as $vbulletin->userinfo stores the user table?

Milad 02-03-2006 01:27 AM

No
Something like $vbulletin->cacheforum

Nullifi3d 02-03-2006 01:34 AM

Sorry, I'm not quite sure what you're referring to. Maybe someone else will know.

Milad 02-03-2006 01:37 AM

$vbulletin->forumcache exactly

thank you

Nullifi3d 02-03-2006 01:48 AM

What do you want to cache? A mysql table (as you said in your first post) or a forum?

Milad 02-03-2006 01:50 AM

Now I'm working on a hack for vBulletin and I want to cache my categories to deal easily with them.

Of course categories are in new table

Nullifi3d 02-03-2006 02:06 AM

In that case you use php code like this:
PHP Code:

$tableinfo $db->query_first("SELECT * FROM " TABLE_PREFIX "tablename WHERE userid = " $_REQUEST['userid']); 

You would change tablename to the name of the mysql table that is storing you hack's data. the * tells mysql to store (cache) each row in that table in the variable $tableinfo (which you can name this whatever you want). This way if you have a row/field named username that stores the usernames for everyone the username for $_REQUEST['userid'] would be called with $tablename['username'];
If you need anymore help let me know.

Milad 02-03-2006 02:11 AM

Dear
This isn't caching, caching makes you avoid this query, I think.

thank you

Nullifi3d 02-03-2006 02:19 AM

Ohh, well I don't know then, sorry.

Adrian Schneider 02-03-2006 02:27 AM

Query it, create a serialized version of the resultset, then insert that into a new datastore column.

Place the colum name in the $specialtemplates array in your script (and unserialize) and you won't have to query for it every time.

Milad 02-03-2006 02:41 AM

THank you
This is exactly what I want
But can you gice a php example?

Adrian Schneider 02-03-2006 03:17 AM

wrote this real quick

PHP Code:

// Preparing
$eggnog $db->query_read("
    SELECT *
    FROM stuff
    ORDER BY stuffName ASC
"
);

$allNogs = array();
while (
$nog $db->fetch_array($eggnog))
{
    
$allNogs[] = $nog;
}

$serialized serialize($allNogs);

$db->query_write("
    UPDATE " 
TABLE_PREFIX "datastore
    SET data = '" 
$db->escape_string($serialized) . "'
    WHERE title = 'nog'
"
);

// Usage

$specialtemplates = array(
    
'nog'
);

require_once(
'./global.php');

//$vbulletin->nog now contains serialized array

$vbulletin->nog unserialize($vbulletin->nog); 


Milad 02-03-2006 06:10 AM

Thank you very much.

Quote:

Originally Posted by SirAdrian
PHP Code:

$db->query_write("
    UPDATE " 
TABLE_PREFIX "datastore
    SET data = '" 
$db->escape_string($serialized) . "'
    WHERE title = 'nog'
"
); 


I think we can use build_datastore instead of this query


All times are GMT. The time now is 02:34 AM.

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.01184 seconds
  • Memory Usage 1,751KB
  • 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
  • (14)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