vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Change data @ $vbulletin->options (https://vborg.vbsupport.ru/showthread.php?t=163279)

Jasiu 11-21-2007 01:05 PM

Change data @ $vbulletin->options
 
Hi,

Well I'm running a plugin that I need to change some things in the datastore, but how can I change a certain element in the datastore?

I know the field name and I can see it in the store and can read the value using $vbulletin->options[' name here '], but how can I change the serialized data stored in the data store?

Opserty 11-21-2007 01:42 PM

If the data is serialized then use PHP: unserialize - Manual

Jasiu 11-21-2007 01:49 PM

Quote:

Originally Posted by Opserty (Post 1386905)
If the data is serialized then use PHP: unserialize - Manual

I know about that, but I mean how do I write stuff to the datastore. I can read the content fine, but how would I update data with new changes?

Andreas 11-21-2007 02:48 PM

PHP Code:

build_datastore($key$data$serialized); 

But for settings I'd suggest to use build_options().

Jasiu 11-21-2007 02:58 PM

Quote:

Originally Posted by Andreas (Post 1386952)
PHP Code:

build_datastore($key$data$serialized); 

But for settings I'd suggest to use build_options().

So when you use build_options() it saves the options from the datastore?

Andreas 11-21-2007 03:17 PM

No, it saves the options from table setting into the datastore.

Jasiu 11-21-2007 03:27 PM

Quote:

Originally Posted by Andreas (Post 1386973)
No, it saves the options from table setting into the datastore.

So what would I do if I wanted to change the values of an array thats in the datastore? I have a field called 'banned_users' which I set the users id in there in the following format " 1,2,3,4 " but I'm making a program to change the values from a custom forum page. The problem I'm having is changing the data already there, I can only change it from the admin cp.

So what would I use to store my new array of ID's in the datastore field 'banned_users'?

Thanks.

Andreas 11-21-2007 05:14 PM

PHP Code:

$db->query_write("UPDATE " TABLE_PREFIX "setting SET value = 'foobar' WHERE varname = 'banned_users'");
require_once(
DIR '/includes/adminfunctions.php');
build_options(); 

You could also just directy change the data in table datastore, but you must keep in mind that it theoreticaally could be changed back at any time if it's not written to table datastore as well.
Also keep datastore caches in mind.

Jasiu 11-21-2007 05:29 PM

Quote:

Originally Posted by Andreas (Post 1387046)
PHP Code:

$db->query_write("UPDATE " TABLE_PREFIX "setting SET value = 'foobar' WHERE varname = 'banned_users'");
require_once(
DIR '/includes/adminfunctions.php');
build_options(); 

You could also just directy change the data in table datastore, but you must keep in mind that it theoreticaally could be changed back at any time if it's not written to table datastore as well.
Also keep datastore caches in mind.

Ahhh thank you very much. While I was waiting for a reply I reverse engineered some of the code and did the query to the setting table like you listed above, but I never got to the point where vB actually updated its values to use the changes.

Thanks again.


All times are GMT. The time now is 05:55 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.02059 seconds
  • Memory Usage 1,737KB
  • 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
  • (4)bbcode_php_printable
  • (4)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (9)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