Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 11-21-2007, 01:05 PM
Jasiu Jasiu is offline
 
Join Date: Aug 2003
Posts: 13
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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?
Reply With Quote
  #2  
Old 11-21-2007, 01:42 PM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If the data is serialized then use PHP: unserialize - Manual
Reply With Quote
  #3  
Old 11-21-2007, 01:49 PM
Jasiu Jasiu is offline
 
Join Date: Aug 2003
Posts: 13
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Opserty View Post
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?
Reply With Quote
  #4  
Old 11-21-2007, 02:48 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
build_datastore($key$data$serialized); 
But for settings I'd suggest to use build_options().
Reply With Quote
  #5  
Old 11-21-2007, 02:58 PM
Jasiu Jasiu is offline
 
Join Date: Aug 2003
Posts: 13
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Andreas View Post
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?
Reply With Quote
  #6  
Old 11-21-2007, 03:17 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

No, it saves the options from table setting into the datastore.
Reply With Quote
  #7  
Old 11-21-2007, 03:27 PM
Jasiu Jasiu is offline
 
Join Date: Aug 2003
Posts: 13
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Andreas View Post
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.
Reply With Quote
  #8  
Old 11-21-2007, 05:14 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #9  
Old 11-21-2007, 05:29 PM
Jasiu Jasiu is offline
 
Join Date: Aug 2003
Posts: 13
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Andreas View Post
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.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:02 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.04162 seconds
  • Memory Usage 2,247KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (4)bbcode_php
  • (4)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (9)post_thanks_box
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (9)post_thanks_postbit_info
  • (9)postbit
  • (9)postbit_onlinestatus
  • (9)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete