vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=251)
-   -   PHP plugin SQL query running multiple SET lines? (https://vborg.vbsupport.ru/showthread.php?t=318558)

Skyrider 05-04-2015 09:34 PM

PHP plugin SQL query running multiple SET lines?
 
I'm trying to run a SQL query code:

Code:

{
$vbulletin->db->query_write("
UPDATE " . TABLE_PREFIX . "user       
SET usergroupid = x
WHERE usergroupid = x");
}

of which appears to be working (with the rest of the other IF codes included), but I can't seem to figure out how to run multiple arrays in a single SET command. for example, with the usergroupID that is being set, I'd like to include the displaygroupid and title as well. I've tried:

Code:

{
$vbulletin->db->query_write("
UPDATE " . TABLE_PREFIX . "user       
SET usergroupid = 10, displaygroupid = 1
WHERE usergroupid = 6");
}

But I appear to be getting a SQL error with that one. Anyone could land a hand?

Side question. If anyone has a better idea how to include the code so the usergroup, eg changes are being logged in to the users history through admincp, please let me know.

ForceHSS 05-04-2015 10:09 PM

UPDATE `user` SET `usergroupid`='10', `displaygroupid`='1' WHERE (`usergroupid`='6')

Skyrider 05-05-2015 06:12 AM

This appears to be working:

Code:

{
$vbulletin->db->query_write("
UPDATE `user` SET `usergroupid`='10', `displaygroupid`='1' WHERE (`usergroupid`='6')");
}

Is this any good? And if I wish to leave an empty result in a table, how would I perform that?

ForceHSS 05-05-2015 08:57 AM

Quote:

Originally Posted by Skyrider (Post 2544916)
This appears to be working:

Code:

{
$vbulletin->db->query_write("
UPDATE `user` SET `usergroupid`='10', `displaygroupid`='1' WHERE (`usergroupid`='6')");
}

Is this any good? And if I wish to leave an empty result in a table, how would I perform that?

The query you have is the one I gave you and yes it will work I always test before I post.

Leaving any of the columns with any empty value will cause an error

Dave 05-05-2015 10:32 AM

Not all columns accept null/empty values, but you can set a column to empty by just using an empty string as follows: somecolumn = ''


All times are GMT. The time now is 12:53 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.01743 seconds
  • Memory Usage 1,720KB
  • 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_code_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)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